mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-05-17 03:04:52 +09:00
Compare commits
16 Commits
ba477c86ad
...
e3ced90bc5
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e3ced90bc5 | ||
![]() |
3eb8d22ddb | ||
![]() |
4e714f9df1 | ||
![]() |
c1ea7f5a24 | ||
![]() |
00d8a07eb6 | ||
![]() |
f7c7ffbd09 | ||
![]() |
2d7b8c95e3 | ||
![]() |
d699bafdfc | ||
![]() |
d6b19dca91 | ||
![]() |
b5676df6da | ||
![]() |
8dced09ed0 | ||
![]() |
c673485d4e | ||
![]() |
06400d1d0f | ||
![]() |
6dd45b8d43 | ||
![]() |
0201ee1082 | ||
![]() |
e24c976035 |
170
youtube_dl/extractor/bandlab.py
Normal file
170
youtube_dl/extractor/bandlab.py
Normal file
@ -0,0 +1,170 @@
|
||||
# coding: utf-8
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from .common import InfoExtractor
|
||||
|
||||
from ..utils import (
|
||||
ExtractorError,
|
||||
merge_dicts,
|
||||
T,
|
||||
traverse_obj,
|
||||
txt_or_none,
|
||||
url_or_none,
|
||||
)
|
||||
|
||||
|
||||
class BandlabIE(InfoExtractor):
|
||||
_VALID_URL = r'https?://(?:www\.)?bandlab\.com/post/(?P<id>[^/]+)'
|
||||
|
||||
_TESTS = [{
|
||||
'url': 'https://www.bandlab.com/post/f5f04998635a44ea819cacdba7ae2076_f8d8574c3bdaec11b6562818783151a1',
|
||||
'info_dict': {
|
||||
'id': 'f5f04998635a44ea819cacdba7ae2076_f8d8574c3bdaec11b6562818783151a1',
|
||||
'ext': 'm4a',
|
||||
'title': 'ON MY OWN (unreleased)',
|
||||
'artist': 'Michael MacDonald',
|
||||
},
|
||||
}]
|
||||
|
||||
def _real_extract(self, url):
|
||||
track_id = self._match_id(url)
|
||||
config = self._download_json(
|
||||
'http://www.bandlab.com/api/v1.3/posts/%s' % track_id, track_id)
|
||||
track_url = traverse_obj(config, ('track', 'sample', 'audioUrl', T(url_or_none)))
|
||||
if not track_url:
|
||||
raise ExtractorError(
|
||||
'[%s] No video formats found!' % (self.ie_key(), ),
|
||||
video_id=track_id, expected=True)
|
||||
title = config['track']['name']
|
||||
|
||||
return {
|
||||
'id': track_id,
|
||||
'title': title,
|
||||
'url': track_url,
|
||||
'artist': traverse_obj(config, ('creator', 'name', T(txt_or_none))),
|
||||
}
|
||||
|
||||
|
||||
class BandlabAlbumOrPlaylistIE(InfoExtractor):
|
||||
_VALID_URL = r'https?://(?:www\.)?bandlab\.com/[^/]+/(?P<kind>albums|collections)/(?P<id>[^/]+)'
|
||||
_TESTS = [{
|
||||
'url': 'https://www.bandlab.com/sbsdasani/albums/dc26e307-e51f-ed11-95d7-002248452390',
|
||||
'playlist': [
|
||||
{
|
||||
'info_dict': {
|
||||
'id': '91feeb36-8e10-4c91-ae57-ffac0a98c6b4',
|
||||
'title': 'How\'d I Lose You? (Intro)',
|
||||
'ext': 'm4a',
|
||||
},
|
||||
},
|
||||
{
|
||||
'info_dict': {
|
||||
'id': 'd87c50a2-70cb-4937-9b97-3ae8646ca3aa',
|
||||
'title': 'Money $$$',
|
||||
'ext': 'm4a',
|
||||
},
|
||||
},
|
||||
{
|
||||
'info_dict': {
|
||||
'id': 'ff2909ff-348f-448d-9d2c-7edbf2f0ec5e',
|
||||
'title': 'You\'ll Be Mine',
|
||||
'ext': 'm4a',
|
||||
},
|
||||
},
|
||||
{
|
||||
'info_dict': {
|
||||
'id': '53786c38-1f3c-4921-9271-793a64af7186',
|
||||
'title': 'Who You Are',
|
||||
'ext': 'm4a',
|
||||
},
|
||||
},
|
||||
{
|
||||
'info_dict': {
|
||||
'id': '0394bb27-113f-4d19-b902-f9c1fe6ba8a8',
|
||||
'title': 'In Your Eyes',
|
||||
'ext': 'm4a',
|
||||
},
|
||||
},
|
||||
{
|
||||
'info_dict': {
|
||||
'id': '2aa44689-c7fa-4d0e-b28a-e0d1dd570372',
|
||||
'title': 'The Same',
|
||||
'ext': 'm4a',
|
||||
},
|
||||
},
|
||||
{
|
||||
'info_dict': {
|
||||
'id': '281fe589-a559-4260-802d-78a6c7a973d8',
|
||||
'title': 'Fall In Love',
|
||||
'ext': 'm4a',
|
||||
},
|
||||
},
|
||||
{
|
||||
'info_dict': {
|
||||
'id': '83a9dc0a-702f-40fd-82f6-ab847f6a7b46',
|
||||
'title': 'Tried So Hard',
|
||||
'ext': 'm4a',
|
||||
},
|
||||
},
|
||||
{
|
||||
'info_dict': {
|
||||
'id': '3f6a4a1c-eb73-449f-bd45-f7958d6f2de1',
|
||||
'title': 'The End Of Everything',
|
||||
'ext': 'm4a',
|
||||
},
|
||||
}
|
||||
],
|
||||
'info_dict': {
|
||||
'id': 'dc26e307-e51f-ed11-95d7-002248452390',
|
||||
'album': 'ENDLESS SUMMER',
|
||||
'artist': 'Michael MacDonald'
|
||||
},
|
||||
}, {
|
||||
'url': 'https://www.bandlab.com/hexatetrahedronx/collections/8fb1041c-e865-eb11-9889-0050f28a2802',
|
||||
'playlist': [
|
||||
{
|
||||
'info_dict': {
|
||||
'id': '8f37e4aa-92c4-eb11-a7ad-0050f280467f',
|
||||
'title': 'psych ward',
|
||||
'ext': 'm4a'
|
||||
}
|
||||
}
|
||||
],
|
||||
'info_dict': {
|
||||
'id': '8fb1041c-e865-eb11-9889-0050f28a2802',
|
||||
'album': 'DOOMTAPE',
|
||||
'artist': '12days'
|
||||
}
|
||||
}]
|
||||
|
||||
def _real_extract(self, url):
|
||||
resource_id, kind = self._match_valid_url(url).group('id', 'kind')
|
||||
config = self._download_json(
|
||||
'http://www.bandlab.com/api/v1.3/%s/%s' % (kind, resource_id), resource_id)
|
||||
entries = []
|
||||
for track in traverse_obj(config, ('posts', Ellipsis)):
|
||||
url, name = (traverse_obj(track, ('track', {
|
||||
'url': ('sample', 'audioUrl', T(url_or_none)),
|
||||
'name': ('name', T(txt_or_none)),
|
||||
}), ('revision', {
|
||||
'url': ('mixdown', 'file', T(url_or_none)),
|
||||
'name': ('song', 'name', T(txt_or_none)),
|
||||
})).get(x) for x in ('url', 'name'))
|
||||
if not (url and name):
|
||||
continue
|
||||
track_id = self._search_regex(
|
||||
r'/([^/]+)\.m4a$', url, 'track id', default=None)
|
||||
if not track_id:
|
||||
continue
|
||||
entries.append({
|
||||
'url': url,
|
||||
'id': track_id,
|
||||
'title': name,
|
||||
})
|
||||
|
||||
return merge_dicts(
|
||||
self.playlist_result(entries, playlist_id=resource_id),
|
||||
traverse_obj(config, {
|
||||
'album': ('name', T(txt_or_none)),
|
||||
'artist': ('creator', 'name', T(txt_or_none)),
|
||||
}))
|
@ -32,7 +32,7 @@ class BokeCCBaseIE(InfoExtractor):
|
||||
|
||||
|
||||
class BokeCCIE(BokeCCBaseIE):
|
||||
_IE_DESC = 'CC视频'
|
||||
IE_DESC = 'CC视频'
|
||||
_VALID_URL = r'https?://union\.bokecc\.com/playvideo\.bo\?(?P<query>.*)'
|
||||
|
||||
_TESTS = [{
|
||||
|
@ -9,7 +9,7 @@ from ..utils import (
|
||||
|
||||
|
||||
class CloudyIE(InfoExtractor):
|
||||
_IE_DESC = 'cloudy.ec'
|
||||
IE_DESC = 'cloudy.ec'
|
||||
_VALID_URL = r'https?://(?:www\.)?cloudy\.ec/(?:v/|embed\.php\?.*?\bid=)(?P<id>[A-Za-z0-9]+)'
|
||||
_TESTS = [{
|
||||
'url': 'https://www.cloudy.ec/v/af511e2527aac',
|
||||
|
@ -422,6 +422,8 @@ class InfoExtractor(object):
|
||||
_GEO_COUNTRIES = None
|
||||
_GEO_IP_BLOCKS = None
|
||||
_WORKING = True
|
||||
# supply this in public subclasses: used in supported sites list, etc
|
||||
# IE_DESC = 'short description of IE'
|
||||
|
||||
def __init__(self, downloader=None):
|
||||
"""Constructor. Receives an optional downloader."""
|
||||
|
@ -98,6 +98,10 @@ from .azmedien import AZMedienIE
|
||||
from .baidu import BaiduVideoIE
|
||||
from .bandaichannel import BandaiChannelIE
|
||||
from .bandcamp import BandcampIE, BandcampAlbumIE, BandcampWeeklyIE
|
||||
from .bandlab import (
|
||||
BandlabIE,
|
||||
BandlabAlbumOrPlaylistIE
|
||||
)
|
||||
from .bbc import (
|
||||
BBCCoUkIE,
|
||||
BBCCoUkArticleIE,
|
||||
|
@ -35,15 +35,6 @@ from ..utils import (
|
||||
|
||||
class ITVBaseIE(InfoExtractor):
|
||||
|
||||
def _search_nextjs_data(self, webpage, video_id, **kw):
|
||||
transform_source = kw.pop('transform_source', None)
|
||||
fatal = kw.pop('fatal', True)
|
||||
return self._parse_json(
|
||||
self._search_regex(
|
||||
r'''<script\b[^>]+\bid=('|")__NEXT_DATA__\1[^>]*>(?P<js>[^<]+)</script>''',
|
||||
webpage, 'next.js data', group='js', fatal=fatal, **kw),
|
||||
video_id, transform_source=transform_source, fatal=fatal)
|
||||
|
||||
def __handle_request_webpage_error(self, err, video_id=None, errnote=None, fatal=True):
|
||||
if errnote is False:
|
||||
return False
|
||||
@ -109,7 +100,9 @@ class ITVBaseIE(InfoExtractor):
|
||||
|
||||
class ITVIE(ITVBaseIE):
|
||||
_VALID_URL = r'https?://(?:www\.)?itv\.com/(?:(?P<w>watch)|hub)/[^/]+/(?(w)[\w-]+/)(?P<id>\w+)'
|
||||
_IE_DESC = 'ITVX'
|
||||
IE_DESC = 'ITVX'
|
||||
_WORKING = False
|
||||
|
||||
_TESTS = [{
|
||||
'note': 'Hub URLs redirect to ITVX',
|
||||
'url': 'https://www.itv.com/hub/liar/2a4547a0012',
|
||||
@ -270,7 +263,7 @@ class ITVIE(ITVBaseIE):
|
||||
'ext': determine_ext(href, 'vtt'),
|
||||
})
|
||||
|
||||
next_data = self._search_nextjs_data(webpage, video_id, fatal=False, default='{}')
|
||||
next_data = self._search_nextjs_data(webpage, video_id, fatal=False, default={})
|
||||
video_data.update(traverse_obj(next_data, ('props', 'pageProps', ('title', 'episode')), expected_type=dict)[0] or {})
|
||||
title = traverse_obj(video_data, 'headerTitle', 'episodeTitle')
|
||||
info = self._og_extract(webpage, require_title=not title)
|
||||
@ -323,7 +316,7 @@ class ITVIE(ITVBaseIE):
|
||||
|
||||
class ITVBTCCIE(ITVBaseIE):
|
||||
_VALID_URL = r'https?://(?:www\.)?itv\.com/(?!(?:watch|hub)/)(?:[^/]+/)+(?P<id>[^/?#&]+)'
|
||||
_IE_DESC = 'ITV articles: News, British Touring Car Championship'
|
||||
IE_DESC = 'ITV articles: News, British Touring Car Championship'
|
||||
_TESTS = [{
|
||||
'note': 'British Touring Car Championship',
|
||||
'url': 'https://www.itv.com/btcc/articles/btcc-2018-all-the-action-from-brands-hatch',
|
||||
|
@ -47,7 +47,7 @@ class SenateISVPIE(InfoExtractor):
|
||||
['vetaff', '76462', 'http://vetaff-f.akamaihd.net'],
|
||||
['arch', '', 'http://ussenate-f.akamaihd.net/']
|
||||
]
|
||||
_IE_NAME = 'senate.gov'
|
||||
IE_NAME = 'senate.gov'
|
||||
_VALID_URL = r'https?://(?:www\.)?senate\.gov/isvp/?\?(?P<qs>.+)'
|
||||
_TESTS = [{
|
||||
'url': 'http://www.senate.gov/isvp/?comm=judiciary&type=live&stt=&filename=judiciary031715&auto_play=false&wmode=transparent&poster=http%3A%2F%2Fwww.judiciary.senate.gov%2Fthemes%2Fjudiciary%2Fimages%2Fvideo-poster-flash-fit.png',
|
||||
|
@ -686,6 +686,8 @@ class JSInterpreter(object):
|
||||
raise self.Exception('Cannot get index {idx!r:.100}'.format(**locals()), expr=repr(obj), cause=e)
|
||||
|
||||
def _dump(self, obj, namespace):
|
||||
if obj is JS_Undefined:
|
||||
return 'undefined'
|
||||
try:
|
||||
return json.dumps(obj)
|
||||
except TypeError:
|
||||
|
Loading…
x
Reference in New Issue
Block a user