Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
yinyajiang committed Jan 7, 2025
1 parent 32f21bd commit bc775d4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug yt-dlp",
"type": "debugpy",
"request": "launch",
"program": "debug.py",
"console": "integratedTerminal",
"justMyCode": false,
//"sudo": true,
"args": [
]
}
]
}
4 changes: 2 additions & 2 deletions debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from yt_dlp import YoutubeDL

ydl = YoutubeDL({
# "cookiefile":'',
# "cookiefile": '',
# 'ignoreerrors': True,
# 'plain_entries': True,
# 'skip_download_media_type': "",
Expand Down Expand Up @@ -77,7 +77,7 @@
)

# ydl.download_with_info_file(os.path.join(current_dir, "debug", "info.json"))
info = ydl.extract_info('url', download=False)
info = ydl.extract_info('https://www.youtube.com/watch?v=kyN623RzFe0', download=False)
s = json.dumps(ydl.sanitize_info(info))
print(s)
with open(os.path.join(current_dir, 'debug', 'info.json'), 'w') as f:
Expand Down
5 changes: 3 additions & 2 deletions yt_dlp/extractor/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,9 @@ def _extract_visitor_data(self, *args):
Extracts visitorData from an API response or ytcfg
Appears to be used to track session state
"""
if visitor_data := self._configuration_arg('visitor_data', [None], ie_key=YoutubeIE, casesense=True)[0]:
return visitor_data
visitor_data_cfg = self._configuration_arg('visitor_data', [None], ie_key=YoutubeIE, casesense=True)
if visitor_data_cfg and len(visitor_data_cfg) > 0:
return visitor_data_cfg[0]
return get_first(
args, [('VISITOR_DATA', ('INNERTUBE_CONTEXT', 'client', 'visitorData'), ('responseContext', 'visitorData'))],
expected_type=str)
Expand Down

0 comments on commit bc775d4

Please sign in to comment.