Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

t.bilibili.com #11726

Open
10 tasks done
finch71 opened this issue Dec 4, 2024 · 4 comments · May be fixed by #11838
Open
10 tasks done

t.bilibili.com #11726

finch71 opened this issue Dec 4, 2024 · 4 comments · May be fixed by #11838
Labels
patch-available There is patch available that should fix this issue. Someone needs to make a PR with it site-enhancement Feature request for some website

Comments

@finch71
Copy link

finch71 commented Dec 4, 2024

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

  • I understand that I will be blocked if I intentionally remove or skip any mandatory* field

Checklist

Region

China

Example URLs

https://t.bilibili.com/998134289197432852

Provide a description that is worded well enough to be understood

obtain video inside a bilibili tweet

Provide verbose output that clearly demonstrates the problem

  • Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
  • If using API, add 'verbose': True to YoutubeDL params instead
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

``
@finch71 finch71 added site-enhancement Feature request for some website triage Untriaged issue labels Dec 4, 2024
@bashonly bashonly added incomplete Further information is needed and removed site-enhancement Feature request for some website triage Untriaged issue labels Dec 4, 2024
@bashonly
Copy link
Member

bashonly commented Dec 4, 2024

that is not complete verbose output

@grqz
Copy link
Contributor

grqz commented Dec 4, 2024

could use API https://api.bilibili.com/x/polymer/web-dynamic/v1/detail(needs wbi signature)

>>> t_id = '998134289197432852'
>>> traverse_obj(self._download_json('https://api.bilibili.com/x/polymer/web-dynamic/v1/detail', t_id, query=self._sign_wbi({'id': t_id}, t_id), headers={
...     'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
... }), ('data', 'item', 'orig', 'modules', 'module_dynamic', 'major', 'archive', 'bvid'))
[BilibiliBase] 998134289197432852: Downloading wbi sign
[BilibiliBase] 998134289197432852: Downloading JSON metadata
'BV1TAmBYVEJr'

EDIT: this doesn't require a wbi signature.
Note for self: another kind of update('dynamic'): 1007126821125226505

@bashonly bashonly added the site-enhancement Feature request for some website label Dec 4, 2024
@grqz
Copy link
Contributor

grqz commented Dec 5, 2024

patch
diff --git a/yt_dlp/extractor/_extractors.py b/yt_dlp/extractor/_extractors.py
index 967010826..e034ed289 100644
--- a/yt_dlp/extractor/_extractors.py
+++ b/yt_dlp/extractor/_extractors.py
@@ -256,6 +256,7 @@
     BilibiliCheeseIE,
     BilibiliCheeseSeasonIE,
     BilibiliCollectionListIE,
+    BiliBiliDynamicIE,
     BilibiliFavoritesListIE,
     BiliBiliIE,
     BiliBiliPlayerIE,
diff --git a/yt_dlp/extractor/bilibili.py b/yt_dlp/extractor/bilibili.py
index 2db951a60..daf89b20d 100644
--- a/yt_dlp/extractor/bilibili.py
+++ b/yt_dlp/extractor/bilibili.py
@@ -32,6 +32,7 @@
     parse_qs,
     parse_resolution,
     qualities,
+    sanitize_url,
     smuggle_url,
     srt_subtitles_timecode,
     str_or_none,
@@ -1861,6 +1862,42 @@ def _real_extract(self, url):
             ie=BiliBiliIE.ie_key(), video_id=video_id)
 
 
+class BiliBiliDynamicIE(InfoExtractor):
+    _VALID_URL = r'https?://(?:t\.bilibili\.com|(?:www\.)?bilibili\.com/opus)/(?P<id>\d+)'
+    _TESTS = [{
+        'url': 'https://t.bilibili.com/998134289197432852',
+        'info_dict': {
+            'id': 'BV1TAmBYVEJr',
+            'ext': 'mp4',
+            'uploader_id': '1192648858',
+            'comment_count': int,
+            '_old_archive_ids': ['bilibili 113457567568273_part1'],
+            'thumbnail': 'http://i2.hdslb.com/bfs/archive/50091efd965d9f13ff6814f7ad374f90ab21e77d.jpg',
+            'duration': 929.238,
+            'upload_date': '20241110',
+            'uploader': '何同学工作室',
+            'like_count': int,
+            'view_count': int,
+            'title': '美国小朋友就玩这个?!何同学工作室11月开箱',
+            'description': '本期产品信息:\n机器狗\n气味模拟器\nCloudboom Strike LS\n无弦吉他\n蓝牙磁带音箱\n神奇画板',
+            'timestamp': 1731232800,
+            'tags': list,
+        },
+    }]
+
+    def _real_extract(self, url):
+        t_id = self._match_id(url)
+        video_url = traverse_obj(self._download_json(
+            'https://api.bilibili.com/x/polymer/web-dynamic/v1/detail', t_id, query={
+                'id': t_id,
+            }, headers={
+                'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
+            }), ('data', 'item', ((), 'orig'), 'modules', 'module_dynamic', (('major', 'archive'), ('additional', 'reserve')), 'jump_url', any, {sanitize_url}))
+        if not video_url:
+            self.raise_no_formats('No video found!', expected=True, video_id=t_id)
+        return self.url_result(video_url)
+
+
 class BiliIntlBaseIE(InfoExtractor):
     _API_URL = 'https://api.bilibili.tv/intl/gateway'
     _NETRC_MACHINE = 'biliintl'

EDIT: added error handling
EDIT2: added bilibili.com/opus urls

I don't want to open a pr for this. This patch is released to the public domain. Anyone can pr this patch if they want

@bashonly bashonly added patch-available There is patch available that should fix this issue. Someone needs to make a PR with it and removed incomplete Further information is needed labels Dec 5, 2024
@bashonly
Copy link
Member

A separate PR needs to be opened for this patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch-available There is patch available that should fix this issue. Someone needs to make a PR with it site-enhancement Feature request for some website
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants