Skip to content

Commit

Permalink
[bilibili] Add support for new URL schema with BV ids (closes #24439,…
Browse files Browse the repository at this point in the history
… closes #24442)
  • Loading branch information
dstftw authored and pareronia committed Jun 22, 2020
1 parent db43af4 commit b3174fe
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions youtube_dl/extractor/bilibili.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@


class BiliBiliIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.|bangumi\.|)bilibili\.(?:tv|com)/(?:video/av|anime/(?P<anime_id>\d+)/play#)(?P<id>\d+)'
_VALID_URL = r'''(?x)
https?://
(?:(?:www|bangumi)\.)?
bilibili\.(?:tv|com)/
(?:
(?:
video/[aA][vV]|
anime/(?P<anime_id>\d+)/play\#
)(?P<id_bv>\d+)|
video/[bB][vV](?P<id>[^/?#&]+)
)
'''

_TESTS = [{
'url': 'http://www.bilibili.tv/video/av1074402/',
Expand Down Expand Up @@ -92,6 +103,10 @@ class BiliBiliIE(InfoExtractor):
'skip_download': True, # Test metadata only
},
}]
}, {
# new BV video id format
'url': 'https://www.bilibili.com/video/BV1JE411F741',
'only_matching': True,
}]

_APP_KEY = 'iVGUTjsxvpLeuDCf'
Expand All @@ -109,7 +124,7 @@ def _real_extract(self, url):
url, smuggled_data = unsmuggle_url(url, {})

mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id')
video_id = mobj.group('id') or mobj.group('id_bv')
anime_id = mobj.group('anime_id')
webpage = self._download_webpage(url, video_id)

Expand Down

0 comments on commit b3174fe

Please sign in to comment.