]>
Commit | Line | Data |
---|---|---|
65493f64 F |
1 | from .common import InfoExtractor |
2 | from ..utils import int_or_none | |
3 | ||
4 | ||
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, | |
9 | headers={ | |
10 | 'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8', | |
11 | 'X-Requested-With': 'XMLHttpRequest', | |
12 | }, data=f'id={player_entry_id}'.encode('utf-8')) | |
13 | ||
14 | return { | |
15 | 'id': str(data_json['entry_id']), | |
16 | 'title': data_json.get('entry_title'), | |
17 | 'url': data_json['path'], | |
18 | 'vcodec': 'none', | |
19 | 'ext': 'mp3', | |
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')), | |
25 | } | |
26 | ||
27 | ||
28 | class AudiodraftCustomIE(AudiodraftBaseIE): | |
29 | IE_NAME = 'Audiodraft:custom' | |
30 | _VALID_URL = r'https?://(?:[-\w]+)\.audiodraft\.com/entry/(?P<id>\d+)' | |
31 | ||
32 | _TESTS = [{ | |
33 | 'url': 'http://nokiatune.audiodraft.com/entry/5874', | |
34 | 'info_dict': { | |
35 | 'id': '9485', | |
36 | 'ext': 'mp3', | |
37 | 'title': 'Hula Hula Calls', | |
38 | 'uploader': 'unclemaki', | |
39 | 'uploader_id': '13512', | |
40 | 'average_rating': 5, | |
41 | 'like_count': int, | |
42 | }, | |
43 | }, { | |
44 | 'url': 'http://vikinggrace.audiodraft.com/entry/501', | |
45 | 'info_dict': { | |
46 | 'id': '22241', | |
47 | 'ext': 'mp3', | |
48 | 'title': 'MVG Happy', | |
49 | 'uploader': 'frog', | |
50 | 'uploader_id': '19142', | |
51 | 'average_rating': 5, | |
52 | 'like_count': int, | |
53 | }, | |
54 | }, { | |
55 | 'url': 'http://timferriss.audiodraft.com/entry/765', | |
56 | 'info_dict': { | |
57 | 'id': '19710', | |
58 | 'ext': 'mp3', | |
59 | 'title': 'ferris03', | |
60 | 'uploader': 'malex', | |
61 | 'uploader_id': '17335', | |
62 | 'average_rating': 5, | |
63 | 'like_count': int, | |
64 | }, | |
65 | }] | |
66 | ||
67 | def _real_extract(self, url): | |
68 | id = self._match_id(url) | |
69 | webpage = self._download_webpage(url, id) | |
70 | player_entry_id = self._search_regex(r'playAudio\(\'(player_entry_\d+)\'\);', webpage, id, 'play entry id') | |
71 | return self._audiodraft_extract_from_id(player_entry_id) | |
72 | ||
73 | ||
74 | class AudiodraftGenericIE(AudiodraftBaseIE): | |
75 | IE_NAME = 'Audiodraft:generic' | |
76 | _VALID_URL = r'https?://www\.audiodraft\.com/contests/[^/#]+#entries&eid=(?P<id>\d+)' | |
77 | ||
78 | _TESTS = [{ | |
79 | 'url': 'https://www.audiodraft.com/contests/570-Score-A-Video-Surprise-Us#entries&eid=30138', | |
80 | 'info_dict': { | |
81 | 'id': '30138', | |
82 | 'ext': 'mp3', | |
83 | 'title': 'DROP in sound_V2', | |
84 | 'uploader': 'TiagoSilva', | |
85 | 'uploader_id': '19452', | |
86 | 'average_rating': 4, | |
87 | 'like_count': int, | |
88 | }, | |
89 | }] | |
90 | ||
91 | def _real_extract(self, url): | |
92 | id = self._match_id(url) | |
93 | return self._audiodraft_extract_from_id(f'player_entry_{id}') |