mirror of
https://github.com/bspeice/playwithfriends
synced 2024-12-21 21:08:09 -05:00
Look up Steam64 ID
This commit is contained in:
parent
10c3b8dcad
commit
82849bfd14
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="Python 3.5.2+ (/usr/bin/python3.5)" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="Python 3.5.2+ virtualenv at /opt/venvs/scientific" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
@ -3,6 +3,7 @@ from enum import Enum
|
|||||||
from os import path
|
from os import path
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
import logging
|
import logging
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
|
|
||||||
_base_url = 'http://api.steampowered.com'
|
_base_url = 'http://api.steampowered.com'
|
||||||
@ -106,3 +107,21 @@ class SteamAPI(object):
|
|||||||
'steamids': steam_id
|
'steamids': steam_id
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_steam64_id(self, profile_url):
|
||||||
|
"""
|
||||||
|
Get the Steam64 ID for a user, given their profile URL.
|
||||||
|
This is by far and above the mostly likely piece of code
|
||||||
|
to break, be careful in the future.
|
||||||
|
|
||||||
|
:param profile_url: Steam community profile URL
|
||||||
|
:type profile_url: str
|
||||||
|
:return: Steam64 ID
|
||||||
|
:rtype: str
|
||||||
|
"""
|
||||||
|
profile_html = requests.get(profile_url)
|
||||||
|
|
||||||
|
soup = BeautifulSoup(profile_html.content, 'lxml')
|
||||||
|
comment_paging = soup.find('div', {'class': 'commentthread_paging'})
|
||||||
|
steamid = comment_paging.attrs['id'].split('_')[2]
|
||||||
|
return steamid
|
||||||
|
10
setup.py
10
setup.py
@ -10,9 +10,15 @@ setup(
|
|||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'requests >= 2.10.0',
|
'requests >= 2.10.0',
|
||||||
'bottle >= 0.12.7'
|
'bottle >= 0.12.7',
|
||||||
|
'BeautifulSoup4 >= 3.2.1'
|
||||||
],
|
],
|
||||||
author='Bradlee Speice',
|
author='Bradlee Speice',
|
||||||
author_email='bradlee.speice@gmail.com',
|
author_email='bradlee.speice@gmail.com',
|
||||||
description='Figure out what games you and your friends should play'
|
description='Figure out what games you and your friends should play',
|
||||||
|
entry_points={
|
||||||
|
'console_scripts': [
|
||||||
|
'playwithfriends = playwithfriends.server:main'
|
||||||
|
]
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
@ -19,3 +19,9 @@ class SteamTest(TestCase):
|
|||||||
steam_id = '76561198020882912'
|
steam_id = '76561198020882912'
|
||||||
games = steam.SteamAPI().get_recent_games(steam_id)
|
games = steam.SteamAPI().get_recent_games(steam_id)
|
||||||
self.assertTrue(len(games) > 0)
|
self.assertTrue(len(games) > 0)
|
||||||
|
|
||||||
|
def test_my_profile_id(self):
|
||||||
|
profile_url = 'http://steamcommunity.com/id/fractalize/'
|
||||||
|
steam_id = '76561198020882912'
|
||||||
|
|
||||||
|
self.assertEqual(steam.SteamAPI().get_steam64_id(profile_url), steam_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user