Skip to content

Commit

Permalink
Merge pull request #51 from soxoj/linktree
Browse files Browse the repository at this point in the history
Added Linktree
  • Loading branch information
soxoj authored Feb 18, 2021
2 parents fa6b17f + bb3c31e commit 380fc13
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
23 changes: 23 additions & 0 deletions socid_extractor/schemes.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,29 @@
'social_links': lambda x: [y.get('url') for y in x['user']['social']],
}
},
'Linktree': {
'flags': ['content="Linktree. Make your link do more."'],
'regex': r'id="__NEXT_DATA__" type="application\/json" crossorigin="anonymous">(.+?)<\/script>',
'extract_json': True,
'transforms': [
json.loads,
lambda x: x['props']['pageProps'],
json.dumps,
],
'fields': {
'id': lambda x: x.get('account', {}).get('id'),
'username': lambda x: x.get('username'),
'image': lambda x: x.get('profilePictureUrl'),
'is_active': lambda x: x.get('account', {}).get('isActive'),
'is_verified': lambda x: x.get('isProfileVerified'),
'facebook_pixel_id': lambda x: x.get('account', {}).get('facebookPixelId'),
'google_analytics_id': lambda x: x.get('account', {}).get('googleAnalyticsId'),
'is_email_verified': lambda x: x.get('account', {}).get('owner', {}).get('isEmailVerified'),
'bio': lambda x: x.get('description'),
'tier': lambda x: x.get('account', {}).get('tier'),
'links': lambda x: [y.get('url') for y in x.get('account', {}).get('links', [])] + x.get('socialLinks', []),
}
},
'Twitch': {
'flags': ['<meta property="al:android:url" content="twitch://'],
'regex': r'id="__NEXT_DATA__" type="application\/json">(.+?)<\/script>',
Expand Down
12 changes: 12 additions & 0 deletions tests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,3 +724,15 @@ def test_twitch():
assert info.get('image_bg') == 'https://static-cdn.jtvnw.net/jtv_user_pictures/9d88705b5a305a7e-profile_banner-480.jpeg'
assert 'views_count' in info
assert 'likes_count' in info

def test_linktree():
info = extract(parse('https://linktr.ee/annetlovart')[0])

assert info.get('id') == '5420275'
assert info.get('username') == 'annetlovart'
assert info.get('image') == 'https://d1fdloi71mui9q.cloudfront.net/MidfykWeQemDO5YVdRDv_35849b5fb49c69271d284ade7ffef659'
assert info.get('is_active') == 'True'
assert info.get('is_verified') == 'True'
assert info.get('is_email_verified') == 'True'
assert info.get('tier') == 'free'
assert info.get('links') == "['https://uk.wikipedia.org/wiki/Annet_Lovart', 'https://www.patreon.com/annetlovart', 'https://creativemarket.com/annet_lovart/4945530-Trendy-Floral-Pattern', 'https://www.behance.net/gallery/96717659/Maya-flowers', 'https://www.facebook.com/annetlovart', 'https://youtu.be/mWU_Lyb9kw4', 'https://instagram.com/annet_lovart', 'https://www.pinterest.com/annet_lovart/one-stroke-tutorial-annet_lovart/']"

0 comments on commit 380fc13

Please sign in to comment.