2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
14 class DroobleIE(InfoExtractor
):
15 _VALID_URL
= r
'''(?x)https?://drooble\.com/(?:
16 (?:(?P<user>[^/]+)/)?(?P<kind>song|videos|music/albums)/(?P<id>\d+)|
17 (?P<user_2>[^/]+)/(?P<kind_2>videos|music))
20 'url': 'https://drooble.com/song/2858030',
21 'md5': '5ffda90f61c7c318dc0c3df4179eb064',
25 'title': 'Skankocillin',
26 'upload_date': '20200801',
27 'timestamp': 1596241390,
28 'uploader_id': '95894',
29 'uploader': 'Bluebeat Shelter',
32 'url': 'https://drooble.com/karl340758/videos/2859183',
36 'title': 'Skankocillin',
37 'uploader_id': 'UCrSRoI5vVyeYihtWEYua7rg',
38 'description': 'md5:ffc0bd8ba383db5341a86a6cd7d9bcca',
39 'upload_date': '20200731',
40 'uploader': 'Bluebeat Shelter',
43 'url': 'https://drooble.com/karl340758/music/albums/2858031',
47 'playlist_mincount': 8,
49 'url': 'https://drooble.com/karl340758/music',
53 'playlist_mincount': 8,
55 'url': 'https://drooble.com/karl340758/videos',
59 'playlist_mincount': 8,
62 def _call_api(self
, method
, video_id
, data
=None):
63 response
= self
._download
_json
(
64 f
'https://drooble.com/api/dt/{method}', video_id
, data
=json
.dumps(data
).encode())
66 raise ExtractorError('Unable to download JSON metadata')
69 def _real_extract(self
, url
):
70 mobj
= self
._match
_valid
_url
(url
)
71 user
= mobj
.group('user') or mobj
.group('user_2')
72 kind
= mobj
.group('kind') or mobj
.group('kind_2')
73 display_id
= mobj
.group('id') or user
75 if mobj
.group('kind_2') == 'videos':
76 data
= {'from_user': display_id, 'album': -1, 'limit': 18, 'offset': 0, 'order': 'new2old', 'type': 'video'}
77 elif kind
in ('music/albums', 'music'):
78 data
= {'user': user, 'public_only': True, 'individual_limit': {'singles': 1, 'albums': 1, 'playlists': 1}
}
80 data
= {'url_slug': display_id, 'children': 10, 'order': 'old2new'}
82 method
= 'getMusicOverview' if kind
in ('music/albums', 'music') else 'getElements'
83 json_data
= self
._call
_api
(method
, display_id
, data
=data
)
84 if kind
in ('music/albums', 'music'):
85 json_data
= json_data
['singles']['list']
88 for media
in json_data
:
89 url
= media
.get('external_media_url') or media
.get('link')
90 if url
.startswith('https://www.youtube.com'):
97 is_audio
= (media
.get('type') or '').lower() == 'audio'
101 'title': media
['title'],
102 'duration': int_or_none(media
.get('duration')),
103 'timestamp': int_or_none(media
.get('timestamp')),
104 'album': try_get(media
, lambda x
: x
['album']['title']),
105 'uploader': try_get(media
, lambda x
: x
['creator']['display_name']),
106 'uploader_id': try_get(media
, lambda x
: x
['creator']['id']),
107 'thumbnail': media
.get('image_comment'),
108 'like_count': int_or_none(media
.get('likes')),
109 'vcodec': 'none' if is_audio
else None,
110 'ext': 'mp3' if is_audio
else None,
114 return self
.playlist_result(entites
, display_id
)