Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
ytdl-patched
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lesmiscore
ytdl-patched
Commits
54c2521c
Unverified
Commit
54c2521c
authored
3 years ago
by
David Skrundz
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[CBC Gem] Extract 1080p formats (#1913)
Authored by: DavidSkrundz
parent
2814f12b
No related branches found
Branches containing commit
Tags
1639276434
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
yt_dlp/extractor/cbc.py
+36
-2
36 additions, 2 deletions
yt_dlp/extractor/cbc.py
with
36 additions
and
2 deletions
yt_dlp/extractor/cbc.py
+
36
−
2
View file @
54c2521c
...
...
@@ -11,11 +11,13 @@
compat_str
,
)
from
..utils
import
(
int_or_none
,
join_nonempty
,
js_to_json
,
smuggle_url
,
try_get
,
orderedSet
,
smuggle_url
,
strip_or_none
,
try_get
,
ExtractorError
,
)
...
...
@@ -313,6 +315,37 @@ def _real_initialize(self):
return
self
.
_claims_token
=
self
.
_downloader
.
cache
.
load
(
self
.
_NETRC_MACHINE
,
'
claims_token
'
)
def
_find_secret_formats
(
self
,
formats
,
video_id
):
"""
Find a valid video url and convert it to the secret variant
"""
base_format
=
next
((
f
for
f
in
formats
if
f
.
get
(
'
vcodec
'
)
!=
'
none
'
),
None
)
if
not
base_format
:
return
base_url
=
re
.
sub
(
r
'
(Manifest\(.*?),filter=[\w-]+(.*?\))
'
,
r
'
\1\2
'
,
base_format
[
'
url
'
])
url
=
re
.
sub
(
r
'
(Manifest\(.*?),format=[\w-]+(.*?\))
'
,
r
'
\1\2
'
,
base_url
)
secret_xml
=
self
.
_download_xml
(
url
,
video_id
,
note
=
'
Downloading secret XML
'
,
fatal
=
False
)
if
not
secret_xml
:
return
for
child
in
secret_xml
:
if
child
.
attrib
.
get
(
'
Type
'
)
!=
'
video
'
:
continue
for
video_quality
in
child
:
bitrate
=
int_or_none
(
video_quality
.
attrib
.
get
(
'
Bitrate
'
))
if
not
bitrate
or
'
Index
'
not
in
video_quality
.
attrib
:
continue
height
=
int_or_none
(
video_quality
.
attrib
.
get
(
'
MaxHeight
'
))
yield
{
**
base_format
,
'
format_id
'
:
join_nonempty
(
'
sec
'
,
height
),
'
url
'
:
re
.
sub
(
r
'
(QualityLevels\()\d+(\))
'
,
fr
'
\<1>
{
bitrate
}
\2
'
,
base_url
),
'
width
'
:
int_or_none
(
video_quality
.
attrib
.
get
(
'
MaxWidth
'
)),
'
tbr
'
:
bitrate
/
1000.0
,
'
height
'
:
height
,
}
def
_real_extract
(
self
,
url
):
video_id
=
self
.
_match_id
(
url
)
video_info
=
self
.
_download_json
(
'
https://services.radio-canada.ca/ott/cbc-api/v2/assets/
'
+
video_id
,
video_id
)
...
...
@@ -335,6 +368,7 @@ def _real_extract(self, url):
formats
=
self
.
_extract_m3u8_formats
(
m3u8_url
,
video_id
,
m3u8_id
=
'
hls
'
)
self
.
_remove_duplicate_formats
(
formats
)
formats
.
extend
(
self
.
_find_secret_formats
(
formats
,
video_id
))
for
format
in
formats
:
if
format
.
get
(
'
vcodec
'
)
==
'
none
'
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment