Compare commits

...

6 Commits

Author SHA1 Message Date
sukkerstjernen
891c293b10
Merge 2358117d39 into b83ca24eb7 2024-11-10 00:54:43 +01:00
sepro
b83ca24eb7
[core] Catch broken Cryptodome installations (#11486)
Authored by: seproDev
2024-11-10 00:53:49 +01:00
bashonly
240a7d43c8
[build] Pin websockets version to >=13.0,<14 (#11488)
websockets 14.0 causes CI test failures (a lot more of them)

Authored by: bashonly
2024-11-09 23:46:47 +00:00
bashonly
f13df591d4
[build] Enable attestations for trusted publishing (#11420)
Reverts 428ffb75aa

Authored by: bashonly
2024-11-09 23:26:02 +00:00
sukkerstjernen
2358117d39
Merge branch 'yt-dlp:master' into master 2024-10-16 13:10:36 +02:00
sukkerstjernen
9ef3e8aaa3 draft for ctc.ru extractor 2024-10-14 16:09:01 +02:00
8 changed files with 221 additions and 8 deletions

View File

@ -504,7 +504,8 @@ jobs:
- windows32
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifact
pattern: build-bin-*

View File

@ -28,3 +28,20 @@ jobs:
actions: write # For cleaning up cache
id-token: write # mandatory for trusted publishing
secrets: inherit
publish_pypi:
needs: [release]
if: vars.MASTER_PYPI_PROJECT != ''
runs-on: ubuntu-latest
permissions:
id-token: write # mandatory for trusted publishing
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
name: build-pypi
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true

View File

@ -41,3 +41,20 @@ jobs:
actions: write # For cleaning up cache
id-token: write # mandatory for trusted publishing
secrets: inherit
publish_pypi:
needs: [release]
if: vars.NIGHTLY_PYPI_PROJECT != ''
runs-on: ubuntu-latest
permissions:
id-token: write # mandatory for trusted publishing
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
name: build-pypi
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true

View File

@ -2,10 +2,6 @@ name: Release
on:
workflow_call:
inputs:
prerelease:
required: false
default: true
type: boolean
source:
required: false
default: ''
@ -18,6 +14,10 @@ on:
required: false
default: ''
type: string
prerelease:
required: false
default: true
type: boolean
workflow_dispatch:
inputs:
source:
@ -278,11 +278,20 @@ jobs:
make clean-cache
python -m build --no-isolation .
- name: Upload artifacts
if: github.event_name != 'workflow_dispatch'
uses: actions/upload-artifact@v4
with:
name: build-pypi
path: |
dist/*
compression-level: 0
- name: Publish to PyPI
if: github.event_name == 'workflow_dispatch'
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
attestations: false # Currently doesn't work w/ reusable workflows (breaks nightly)
publish:
needs: [prepare, build]

View File

@ -52,7 +52,7 @@ default = [
"pycryptodomex",
"requests>=2.32.2,<3",
"urllib3>=1.26.17,<3",
"websockets>=13.0",
"websockets>=13.0,<14",
]
curl-cffi = [
"curl-cffi==0.5.10; os_name=='nt' and implementation_name=='cpython'",

View File

@ -24,7 +24,7 @@ try:
from Crypto.Cipher import AES, PKCS1_OAEP, Blowfish, PKCS1_v1_5 # noqa: F401
from Crypto.Hash import CMAC, SHA1 # noqa: F401
from Crypto.PublicKey import RSA # noqa: F401
except ImportError:
except (ImportError, OSError):
__version__ = f'broken {__version__}'.strip()

View File

@ -446,6 +446,11 @@ from .cspan import (
CSpanCongressIE,
CSpanIE,
)
from .ctc import (
CTCIE,
CTCSeasonIE,
CTCSeriesIE,
)
from .ctsnews import CtsNewsIE
from .ctv import CTVIE
from .ctvnews import CTVNewsIE

164
yt_dlp/extractor/ctc.py Normal file
View File

@ -0,0 +1,164 @@
from .common import InfoExtractor
from ..utils import (
traverse_obj,
int_or_none
)
class CTCIE(InfoExtractor):
IE_NAME = 'ctc'
_VALID_URL = (
r'https?://ctc\.ru/projects/filmi/(?P<project_name>[^/]+)/?(?:video/?)?$'
r'|https?://ctc\.ru/projects/(?P<category>show|multiki|serials)/(?P<project_name2>[^/]+)/video/'
r'(?:$'
r'|(?P<season_number>\d+)-sezon/(?P<episode_number>\d+)-(?:vypusk|serija)/?$'
r'|promo/[^/]+/?$'
r')'
)
_GEO_COUNTRIES = ['RU']
def _real_extract(self, url):
url_slug = url.split("https://ctc.ru/")[1]
item_response = self._download_json(
f'https://ctc.ru/api/page/v1/{url_slug}', url_slug,
note='Downloading item data', headers={
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0"
}
)
track_hub_id = str(traverse_obj(item_response, ('content', 0, 'trackHubId'), expected_type=int))
if not track_hub_id:
self.raise_no_formats('trackHubId not found')
video_url = traverse_obj(
item_response, ('content', 0, 'videoUrl'), get_all=False
) or traverse_obj(
item_response, ('content', 0, 'trackUrl'), get_all=False
)
stream_response = self._download_json(
video_url.replace("/player/", "/playlist/"),
track_hub_id,
note='Downloading stream data', headers={
'X-Referer': 'https://ctc.ru',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0',
}
)
if traverse_obj(stream_response, ('playlist', 'items', 0, 'errors', 0, 'code')) == 102:
self.raise_geo_restricted(countries=self._GEO_COUNTRIES)
elif traverse_obj(stream_response, ('playlist', 'items', 0, 'errors', 0, 'code')) == 103:
self.raise_login_required(msg='This video is only available for registered users with the required subscription')
formats = []
for stream in traverse_obj(stream_response, ('playlist', 'items', 0, 'streams')):
protocol = stream.get('protocol')
video_id = traverse_obj(stream_response, ('playlist', 'items', 0, 'track_id'))
fmts = []
if protocol == 'HLS':
fmts, _ = self._extract_m3u8_formats_and_subtitles(
stream.get('url'), video_id, ext='mp4', preference=1, m3u8_id="video/hls", fatal=False)
formats.extend(fmts)
return {
'formats': formats,
'id': track_hub_id,
'title': ": ".join(filter(None, [
traverse_obj(stream_response, ('playlist', 'items', 0, 'project_name')),
traverse_obj(stream_response, ('playlist', 'items', 0, 'episode_name'))
])),
**traverse_obj(item_response, {
'description': ('content', 0, 'description'),
}),
**traverse_obj(stream_response, {
'episode': ('playlist', 'items', 0, 'episode_name'),
'duration': ('playlist', 'items', 0, 'duration'),
'thumbnail': ('playlist', 'items', 0, 'thumbnail_url'),
'season': ('playlist', 'items', 0, 'season_name'),
'age_limit': ('playlist', 'items', 0, 'min_age'),
}),
'season_number': int_or_none(self._match_valid_url(url).group('season_number')),
'episode_number': int_or_none(self._match_valid_url(url).group('episode_number')),
}
class CTCSeasonIE(InfoExtractor):
IE_NAME = 'ctc:season'
_VALID_URL = (
r'https?://ctc\.ru/projects/(?P<category>show|multiki|serials)/'
r'(?P<project_name>[^/]+)/video/(?P<season_number>\d+)-sezon/?$'
)
_GEO_COUNTRIES = ['RU']
def _real_extract(self, url):
url_slug = url.split("https://ctc.ru/")[1]
season_data = self._download_json(f'https://ctc.ru/api/page/v1/{url_slug}', url_slug)
entries = [{
'_type': 'url',
'title': episode.get('title'),
'url': f"https://ctc.ru{episode.get('popupUrl')}",
'ie_key': CTCIE.ie_key(),
'season_number': self._match_valid_url(url).group('season_number'),
'episode_number': self._search_regex(
r'/(?P<episode>\d+)-(vypusk|serija)/',
episode.get('popupUrl'),
'episode number',
)
} for episode in traverse_obj(season_data, ('content', 1, 'widgets')) if episode.get('popupUrl')]
return {
'_type': 'playlist',
'entries': entries,
**traverse_obj(season_data, {
'id': ('content', 9, 'entityId'),
'title': ('content', 0, 'widgets', 1, 'title'),
'season_number': self._match_valid_url(url).group('season_number'),
'series': ('content', 0, 'widgets', 1, 'title'),
'description': ('content', 0, 'widgets', 1, 'description'),
}),
}
class CTCSeriesIE(InfoExtractor):
IE_NAME = 'ctc:series'
_VALID_URL = (
r'https?://ctc\.ru/projects/(?P<category>show|multiki|serials)/'
r'(?P<slug>[^/]+)/?$'
)
_GEO_COUNTRIES = ['RU']
def _real_extract(self, url):
url_slug = url.split("https://ctc.ru/")[1]
series_data = self._download_json(f'https://ctc.ru/api/page/v1/{url_slug}', url_slug)
# cartoons doesn't indicate in the url what type it is, so
# if it's a movie, then redirect it to CTCIE
if traverse_obj(series_data, ('content', 5, 'tabs')) == []:
return self.url_result(f'https://ctc.ru/{url_slug}/video')
entries = [{
'_type': 'url',
'title': season.get('title'),
'url': f'https://ctc.ru{season.get("url")}',
'ie_key': CTCSeasonIE.ie_key(),
'season_number': self._search_regex(
r'/(?P<episode>\d+)-sezon/',
season.get("url"),
'season number',
),
'series': season.get('title'),
} for season in traverse_obj(series_data, ('content', 1, 'tabs')) if season.get("url").endswith("sezon/")]
return {
'_type': 'playlist',
'entries': entries,
**traverse_obj(series_data, {
'id': ('content', 0, 'projectId'),
'title': ('content', 0, 'widgets', 1, 'title'),
'series': ('content', 0, 'widgets', 1, 'title'),
'description': ('content', 0, 'widgets', 1, 'description')
}),
}