1 from .common
import InfoExtractor
2 from ..utils
import int_or_none
5 class AudiodraftBaseIE(InfoExtractor
):
6 def _audiodraft_extract_from_id(self
, player_entry_id
):
7 data_json
= self
._download
_json
(
8 'https://www.audiodraft.com/scripts/general/player/getPlayerInfoNew.php', player_entry_id
,
10 'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
11 'X-Requested-With': 'XMLHttpRequest',
12 }, data
=f
'id={player_entry_id}'.encode())
15 'id': str(data_json
['entry_id']),
16 'title': data_json
.get('entry_title'),
17 'url': data_json
['path'],
20 'uploader': data_json
.get('designer_name'),
21 'uploader_id': data_json
.get('designer_id'),
22 'webpage_url': data_json
.get('entry_url'),
23 'like_count': int_or_none(data_json
.get('entry_likes')),
24 'average_rating': int_or_none(data_json
.get('entry_rating')),
28 class AudiodraftCustomIE(AudiodraftBaseIE
):
29 IE_NAME
= 'Audiodraft:custom'
30 _VALID_URL
= r
'https?://(?:[-\w]+)\.audiodraft\.com/entry/(?P<id>\d+)'
33 'url': 'http://nokiatune.audiodraft.com/entry/5874',
37 'title': 'Hula Hula Calls',
38 'uploader': 'unclemaki',
39 'uploader_id': '13512',
44 'url': 'http://vikinggrace.audiodraft.com/entry/501',
50 'uploader_id': '19142',
55 'url': 'http://timferriss.audiodraft.com/entry/765',
61 'uploader_id': '17335',
67 def _real_extract(self
, url
):
68 video_id
= self
._match
_id
(url
)
69 webpage
= self
._download
_webpage
(url
, video_id
)
70 player_entry_id
= self
._search
_regex
(
71 r
'playAudio\(\'(player_entry_\d
+)\'\
);', webpage, video_id, 'play entry
id')
72 return self._audiodraft_extract_from_id(player_entry_id)
75 class AudiodraftGenericIE(AudiodraftBaseIE):
76 IE_NAME = 'Audiodraft
:generic
'
77 _VALID_URL = r'https?
://www\
.audiodraft\
.com
/contests
/[^
/#]+#entries&eid=(?P<id>\d+)'
80 'url': 'https://www.audiodraft.com/contests/570-Score-A-Video-Surprise-Us#entries&eid=30138',
84 'title': 'DROP in sound_V2',
85 'uploader': 'TiagoSilva',
86 'uploader_id': '19452',
92 def _real_extract(self
, url
):
93 video_id
= self
._match
_id
(url
)
94 return self
._audiodraft
_extract
_from
_id
(f
'player_entry_{video_id}')