Skip to content

Commit

Permalink
Reddit, Twitch and Last.fm fixes (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
soxoj authored Nov 15, 2021
1 parent b80782e commit 5e6ac9c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
13 changes: 8 additions & 5 deletions socid_extractor/schemes.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,8 +820,11 @@
'has_user_profile': lambda x: x['hasUserProfile'],
'hide_from_robots': lambda x: x['hideFromRobots'],
'created_at': lambda x: timestamp_to_datetime(x['createdUtc']),
'total_karma': lambda x: x['totalKarma'],
'post_karma': lambda x: x['postKarma'],
'total_karma': lambda x: x['karma']['total'],
'post_karma': lambda x: x['karma']['fromPosts'],
'comments_karma': lambda x: x['karma']['fromComments'],
'awards_given_karma': lambda x: x['karma']['fromAwardsGiven'],
'awards_got_karma': lambda x: x['karma']['fromAwardsReceived'],
},
},
'Steam': {
Expand Down Expand Up @@ -1131,16 +1134,16 @@
json.loads,
lambda x: x['props']['relayQueryRecords'],
lambda x: [v for k, v in x.items() if k.startswith('User') or k.endswith('followers')],
lambda x: dict(list(x[0].items()) + list(x[1].items())),
lambda x: dict(list(x[-1].items()) + list(x[0].items())),
json.dumps,
],
'fields': {
'id': lambda x: x.get('id').split('{')[-1],
'views_count': lambda x: x.get('profileViewCount'),
# 'views_count': lambda x: x.get('profileViewCount'),
'username': lambda x: x.get('login'),
'bio': lambda x: x.get('description'),
'fullname': lambda x: x.get('displayName'),
'image': lambda x: x.get('profileImageURL(width:300)'),
'image': lambda x: x.get('profileImageURL(width:150)'),
'likes_count': lambda x: x.get('totalCount'),
'image_bg': lambda x: x.get('bannerImageURL'),
},
Expand Down
3 changes: 3 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pytest==6.2.5
pytest-rerunfailures==9.1.1
pytest-xdist==2.2.1
10 changes: 5 additions & 5 deletions tests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def test_reddit():
assert info.get('reddit_username') == 'Diascamara'
assert info.get('fullname') == 'Diascamara'
assert info.get('is_employee') == 'False'
assert info.get('is_nsfw') == 'False'
assert info.get('is_nsfw') == 'True'
assert info.get('is_mod') == 'True'
assert info.get('is_following') == 'True'
assert info.get('has_user_profile') == 'True'
Expand Down Expand Up @@ -776,7 +776,7 @@ def test_last_fm():

assert info.get('fullname') == 'Alex'
assert info.get('bio') == '• scrobbling since 21 Feb 2003'
assert info.get('image') == 'https://lastfm.freetls.fastly.net/i/u/avatar170s/15e455555655c8503ed9ba6fce71d2d6.webp'
assert info.get('image') == 'https://lastfm.freetls.fastly.net/i/u/avatar170s/15e455555655c8503ed9ba6fce71d2d6.png'


def test_ask_fm():
Expand Down Expand Up @@ -807,11 +807,11 @@ def test_twitch():

assert info.get('id') == '36536868'
assert info.get('username') == 'johnwolfe'
assert info.get('bio') == 'Playing horror games all the time for charity.'
assert info.get('bio') == 'Horror games. Dead By Daylight. Charity streams. '
assert info.get('fullname') == 'JohnWolfe'
assert info.get('image') == 'https://static-cdn.jtvnw.net/jtv_user_pictures/johnwolfe-profile_image-61f8e374d34a8bbd-300x300.png'
assert info.get('image') == 'https://static-cdn.jtvnw.net/jtv_user_pictures/johnwolfe-profile_image-61f8e374d34a8bbd-150x150.png'
assert info.get('image_bg') == 'https://static-cdn.jtvnw.net/jtv_user_pictures/9d88705b5a305a7e-profile_banner-480.jpeg'
assert 'views_count' in info
# assert 'views_count' in info
assert 'likes_count' in info


Expand Down

0 comments on commit 5e6ac9c

Please sign in to comment.