Skip to content

Commit 6ed932c

Browse files
committed
Added yandex-username-to-email postprocessor, bump to 0.0.20
1 parent 7480a5c commit 6ed932c

5 files changed

Lines changed: 26 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased]
44

5+
## [0.0.20] - 2021-05-15
6+
* fixed email-to-username postprocessor bug
7+
* added yandex-username-to-email postprocessor
8+
59
## [0.0.19] - 2021-05-12
610
* non-json transforms
711
* added Weibo and Trello

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
long_description = fh.read()
99

1010
setup(name='socid-extractor',
11-
version='0.0.19',
11+
version='0.0.20',
1212
description='Extract accounts\' identifiers from personal pages on various platforms',
1313
long_description=long_description,
1414
long_description_content_type="text/markdown",

socid_extractor/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from .main import extract, parse, parse_cookies, mutate_url
22

3-
__version__ = '0.0.19'
3+
__version__ = '0.0.20'
44
__title__ = 'socid_extractor'
55
__package__ = 'socid_extractor'
66
__author__ = 'soxoj'

socid_extractor/postprocessor.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ def process(self):
4848
return output
4949

5050

51-
class Email:
51+
class EmailToUsername:
5252
def __init__(self, data):
5353
self.data = data
5454

5555
def process(self):
5656
output = {}
5757

5858
for k, v in self.data.items():
59-
if v.startswith('[') or v.startswith("'"):
59+
if v[0] in "'[{\"":
6060
continue
6161
if 'email' in k and '@' in v:
6262
new_k = k + '_username'
@@ -66,4 +66,20 @@ def process(self):
6666
return output
6767

6868

69-
POSTPROCESSORS = [Gravatar, Email]
69+
class YandexUsernameToEmail:
70+
def __init__(self, data):
71+
self.data = data
72+
73+
def process(self):
74+
output = {}
75+
email = None
76+
77+
if 'yandex_uid' in self.data or 'yandex_public_id' in self.data:
78+
if 'username' in self.data:
79+
email = self.data['username'] + '@yandex.ru'
80+
output['email'] = email
81+
82+
return output
83+
84+
85+
POSTPROCESSORS = [Gravatar, EmailToUsername, YandexUsernameToEmail]

tests/test_e2e.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,10 @@ def test_yandex_music_user_profile():
269269
assert info.get('username') == 'pritisk'
270270
assert info.get('name') == 'Юрий Притиск'
271271
assert info.get('image') == 'https://avatars.mds.yandex.net/get-yapic/29310/gK74BTyv8LrLRT0mQFIR2xcWv8-1/islands-200'
272-
assert info.get('links') == '[]'
273272
assert info.get('is_verified') == 'False'
274273
assert info.get('liked_albums') == '0'
275274
assert info.get('liked_artists') == '0'
275+
assert info.get('email') == 'pritisk@yandex.ru'
276276

277277

278278
@pytest.mark.skip(reason="failed from github CI infra IPs")

0 commit comments

Comments
 (0)