mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-26 17:21:23 +01:00
Compare commits
16 Commits
575c175f96
...
d54745d5db
Author | SHA1 | Date | |
---|---|---|---|
|
d54745d5db | ||
|
b83ca24eb7 | ||
|
240a7d43c8 | ||
|
f13df591d4 | ||
|
be3579aaf0 | ||
|
85fdc66b6e | ||
|
a44a1a86b9 | ||
|
2936efb71c | ||
|
b7d4c50ef3 | ||
|
772e292c33 | ||
|
5b1a168cea | ||
|
21a35b5264 | ||
|
13b92fe1a3 | ||
|
56ae6a975b | ||
|
f9c47b9343 | ||
|
f0cea43cde |
3
.github/workflows/build.yml
vendored
3
.github/workflows/build.yml
vendored
|
@ -504,7 +504,8 @@ jobs:
|
||||||
- windows32
|
- windows32
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v4
|
- name: Download artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
path: artifact
|
path: artifact
|
||||||
pattern: build-bin-*
|
pattern: build-bin-*
|
||||||
|
|
17
.github/workflows/release-master.yml
vendored
17
.github/workflows/release-master.yml
vendored
|
@ -28,3 +28,20 @@ jobs:
|
||||||
actions: write # For cleaning up cache
|
actions: write # For cleaning up cache
|
||||||
id-token: write # mandatory for trusted publishing
|
id-token: write # mandatory for trusted publishing
|
||||||
secrets: inherit
|
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
|
||||||
|
|
17
.github/workflows/release-nightly.yml
vendored
17
.github/workflows/release-nightly.yml
vendored
|
@ -41,3 +41,20 @@ jobs:
|
||||||
actions: write # For cleaning up cache
|
actions: write # For cleaning up cache
|
||||||
id-token: write # mandatory for trusted publishing
|
id-token: write # mandatory for trusted publishing
|
||||||
secrets: inherit
|
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
|
||||||
|
|
19
.github/workflows/release.yml
vendored
19
.github/workflows/release.yml
vendored
|
@ -2,10 +2,6 @@ name: Release
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
prerelease:
|
|
||||||
required: false
|
|
||||||
default: true
|
|
||||||
type: boolean
|
|
||||||
source:
|
source:
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
|
@ -18,6 +14,10 @@ on:
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
type: string
|
type: string
|
||||||
|
prerelease:
|
||||||
|
required: false
|
||||||
|
default: true
|
||||||
|
type: boolean
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
source:
|
source:
|
||||||
|
@ -278,11 +278,20 @@ jobs:
|
||||||
make clean-cache
|
make clean-cache
|
||||||
python -m build --no-isolation .
|
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
|
- name: Publish to PyPI
|
||||||
|
if: github.event_name == 'workflow_dispatch'
|
||||||
uses: pypa/gh-action-pypi-publish@release/v1
|
uses: pypa/gh-action-pypi-publish@release/v1
|
||||||
with:
|
with:
|
||||||
verbose: true
|
verbose: true
|
||||||
attestations: false # Currently doesn't work w/ reusable workflows (breaks nightly)
|
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
needs: [prepare, build]
|
needs: [prepare, build]
|
||||||
|
|
|
@ -52,7 +52,7 @@ default = [
|
||||||
"pycryptodomex",
|
"pycryptodomex",
|
||||||
"requests>=2.32.2,<3",
|
"requests>=2.32.2,<3",
|
||||||
"urllib3>=1.26.17,<3",
|
"urllib3>=1.26.17,<3",
|
||||||
"websockets>=13.0",
|
"websockets>=13.0,<14",
|
||||||
]
|
]
|
||||||
curl-cffi = [
|
curl-cffi = [
|
||||||
"curl-cffi==0.5.10; os_name=='nt' and implementation_name=='cpython'",
|
"curl-cffi==0.5.10; os_name=='nt' and implementation_name=='cpython'",
|
||||||
|
|
|
@ -24,7 +24,7 @@ try:
|
||||||
from Crypto.Cipher import AES, PKCS1_OAEP, Blowfish, PKCS1_v1_5 # noqa: F401
|
from Crypto.Cipher import AES, PKCS1_OAEP, Blowfish, PKCS1_v1_5 # noqa: F401
|
||||||
from Crypto.Hash import CMAC, SHA1 # noqa: F401
|
from Crypto.Hash import CMAC, SHA1 # noqa: F401
|
||||||
from Crypto.PublicKey import RSA # noqa: F401
|
from Crypto.PublicKey import RSA # noqa: F401
|
||||||
except ImportError:
|
except (ImportError, OSError):
|
||||||
__version__ = f'broken {__version__}'.strip()
|
__version__ = f'broken {__version__}'.strip()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -708,6 +708,7 @@ from .gab import (
|
||||||
GabTVIE,
|
GabTVIE,
|
||||||
)
|
)
|
||||||
from .gaia import GaiaIE
|
from .gaia import GaiaIE
|
||||||
|
from .gamedevtv import GameDevTVDashboardIE
|
||||||
from .gamejolt import (
|
from .gamejolt import (
|
||||||
GameJoltCommunityIE,
|
GameJoltCommunityIE,
|
||||||
GameJoltGameIE,
|
GameJoltGameIE,
|
||||||
|
|
|
@ -1362,7 +1362,7 @@ class AdobePassIE(InfoExtractor): # XXX: Conventionally, base classes should en
|
||||||
|
|
||||||
def _download_webpage_handle(self, *args, **kwargs):
|
def _download_webpage_handle(self, *args, **kwargs):
|
||||||
headers = self.geo_verification_headers()
|
headers = self.geo_verification_headers()
|
||||||
headers.update(kwargs.get('headers', {}))
|
headers.update(kwargs.get('headers') or {})
|
||||||
kwargs['headers'] = headers
|
kwargs['headers'] = headers
|
||||||
return super()._download_webpage_handle(
|
return super()._download_webpage_handle(
|
||||||
*args, **kwargs)
|
*args, **kwargs)
|
||||||
|
|
141
yt_dlp/extractor/gamedevtv.py
Normal file
141
yt_dlp/extractor/gamedevtv.py
Normal file
|
@ -0,0 +1,141 @@
|
||||||
|
import json
|
||||||
|
|
||||||
|
from .common import InfoExtractor
|
||||||
|
from ..networking.exceptions import HTTPError
|
||||||
|
from ..utils import (
|
||||||
|
ExtractorError,
|
||||||
|
clean_html,
|
||||||
|
int_or_none,
|
||||||
|
join_nonempty,
|
||||||
|
parse_iso8601,
|
||||||
|
str_or_none,
|
||||||
|
url_or_none,
|
||||||
|
)
|
||||||
|
from ..utils.traversal import traverse_obj
|
||||||
|
|
||||||
|
|
||||||
|
class GameDevTVDashboardIE(InfoExtractor):
|
||||||
|
_VALID_URL = r'https?://(?:www\.)?gamedev\.tv/dashboard/courses/(?P<course_id>\d+)(?:/(?P<lecture_id>\d+))?'
|
||||||
|
_NETRC_MACHINE = 'gamedevtv'
|
||||||
|
_TESTS = [{
|
||||||
|
'url': 'https://www.gamedev.tv/dashboard/courses/25',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '25',
|
||||||
|
'title': 'Complete Blender Creator 3: Learn 3D Modelling for Beginners',
|
||||||
|
'tags': ['blender', 'course', 'all', 'box modelling', 'sculpting'],
|
||||||
|
'categories': ['Blender', '3D Art'],
|
||||||
|
'thumbnail': 'https://gamedev-files.b-cdn.net/courses/qisc9pmu1jdc.jpg',
|
||||||
|
'upload_date': '20220516',
|
||||||
|
'timestamp': 1652694420,
|
||||||
|
'modified_date': '20241027',
|
||||||
|
'modified_timestamp': 1730049658,
|
||||||
|
},
|
||||||
|
'playlist_count': 100,
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.gamedev.tv/dashboard/courses/63/2279',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'df04f4d8-68a4-4756-a71b-9ca9446c3a01',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'modified_timestamp': 1701695752,
|
||||||
|
'upload_date': '20230504',
|
||||||
|
'episode': 'MagicaVoxel Community Course Introduction',
|
||||||
|
'series_id': '63',
|
||||||
|
'title': 'MagicaVoxel Community Course Introduction',
|
||||||
|
'timestamp': 1683195397,
|
||||||
|
'modified_date': '20231204',
|
||||||
|
'categories': ['3D Art', 'MagicaVoxel'],
|
||||||
|
'season': 'MagicaVoxel Community Course',
|
||||||
|
'tags': ['MagicaVoxel', 'all', 'course'],
|
||||||
|
'series': 'MagicaVoxel 3D Art Mini Course',
|
||||||
|
'duration': 1405,
|
||||||
|
'episode_number': 1,
|
||||||
|
'season_number': 1,
|
||||||
|
'season_id': '219',
|
||||||
|
'description': 'md5:a378738c5bbec1c785d76c067652d650',
|
||||||
|
'display_id': '63-219-2279',
|
||||||
|
'alt_title': '1_CC_MVX MagicaVoxel Community Course Introduction.mp4',
|
||||||
|
'thumbnail': 'https://vz-23691c65-6fa.b-cdn.net/df04f4d8-68a4-4756-a71b-9ca9446c3a01/thumbnail.jpg',
|
||||||
|
},
|
||||||
|
}]
|
||||||
|
_API_HEADERS = {}
|
||||||
|
|
||||||
|
def _perform_login(self, username, password):
|
||||||
|
try:
|
||||||
|
response = self._download_json(
|
||||||
|
'https://api.gamedev.tv/api/students/login', None, 'Logging in',
|
||||||
|
headers={'Content-Type': 'application/json'},
|
||||||
|
data=json.dumps({
|
||||||
|
'email': username,
|
||||||
|
'password': password,
|
||||||
|
'cart_items': [],
|
||||||
|
}).encode())
|
||||||
|
except ExtractorError as e:
|
||||||
|
if isinstance(e.cause, HTTPError) and e.cause.status == 401:
|
||||||
|
raise ExtractorError('Invalid username/password', expected=True)
|
||||||
|
raise
|
||||||
|
|
||||||
|
self._API_HEADERS['Authorization'] = f'{response["token_type"]} {response["access_token"]}'
|
||||||
|
|
||||||
|
def _real_initialize(self):
|
||||||
|
if not self._API_HEADERS.get('Authorization'):
|
||||||
|
self.raise_login_required(
|
||||||
|
'This content is only available with purchase', method='password')
|
||||||
|
|
||||||
|
def _entries(self, data, course_id, course_info, selected_lecture):
|
||||||
|
for section in traverse_obj(data, ('sections', ..., {dict})):
|
||||||
|
section_info = traverse_obj(section, {
|
||||||
|
'season_id': ('id', {str_or_none}),
|
||||||
|
'season': ('title', {str}),
|
||||||
|
'season_number': ('order', {int_or_none}),
|
||||||
|
})
|
||||||
|
for lecture in traverse_obj(section, ('lectures', lambda _, v: url_or_none(v['video']['playListUrl']))):
|
||||||
|
if selected_lecture and str(lecture.get('id')) != selected_lecture:
|
||||||
|
continue
|
||||||
|
display_id = join_nonempty(course_id, section_info.get('season_id'), lecture.get('id'))
|
||||||
|
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
|
||||||
|
lecture['video']['playListUrl'], display_id, 'mp4', m3u8_id='hls')
|
||||||
|
yield {
|
||||||
|
**course_info,
|
||||||
|
**section_info,
|
||||||
|
'id': display_id, # fallback
|
||||||
|
'display_id': display_id,
|
||||||
|
'formats': formats,
|
||||||
|
'subtitles': subtitles,
|
||||||
|
'series': course_info.get('title'),
|
||||||
|
'series_id': course_id,
|
||||||
|
**traverse_obj(lecture, {
|
||||||
|
'id': ('video', 'guid', {str}),
|
||||||
|
'title': ('title', {str}),
|
||||||
|
'alt_title': ('video', 'title', {str}),
|
||||||
|
'description': ('description', {clean_html}),
|
||||||
|
'episode': ('title', {str}),
|
||||||
|
'episode_number': ('order', {int_or_none}),
|
||||||
|
'duration': ('video', 'duration_in_sec', {int_or_none}),
|
||||||
|
'timestamp': ('video', 'created_at', {parse_iso8601}),
|
||||||
|
'modified_timestamp': ('video', 'updated_at', {parse_iso8601}),
|
||||||
|
'thumbnail': ('video', 'thumbnailUrl', {url_or_none}),
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
|
||||||
|
def _real_extract(self, url):
|
||||||
|
course_id, lecture_id = self._match_valid_url(url).group('course_id', 'lecture_id')
|
||||||
|
data = self._download_json(
|
||||||
|
f'https://api.gamedev.tv/api/courses/my/{course_id}', course_id,
|
||||||
|
headers=self._API_HEADERS)['data']
|
||||||
|
|
||||||
|
course_info = traverse_obj(data, {
|
||||||
|
'title': ('title', {str}),
|
||||||
|
'tags': ('tags', ..., 'name', {str}),
|
||||||
|
'categories': ('categories', ..., 'title', {str}),
|
||||||
|
'timestamp': ('created_at', {parse_iso8601}),
|
||||||
|
'modified_timestamp': ('updated_at', {parse_iso8601}),
|
||||||
|
'thumbnail': ('image', {url_or_none}),
|
||||||
|
})
|
||||||
|
|
||||||
|
entries = self._entries(data, course_id, course_info, lecture_id)
|
||||||
|
if lecture_id:
|
||||||
|
lecture = next(entries, None)
|
||||||
|
if not lecture:
|
||||||
|
raise ExtractorError('Lecture not found')
|
||||||
|
return lecture
|
||||||
|
return self.playlist_result(entries, course_id, **course_info)
|
|
@ -2,25 +2,27 @@ from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
float_or_none,
|
float_or_none,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
remove_end,
|
|
||||||
strip_or_none,
|
strip_or_none,
|
||||||
traverse_obj,
|
traverse_obj,
|
||||||
url_or_none,
|
url_or_none,
|
||||||
|
urlhandle_detect_ext,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class NZOnScreenIE(InfoExtractor):
|
class NZOnScreenIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://www\.nzonscreen\.com/title/(?P<id>[^/?#]+)'
|
_VALID_URL = r'https?://www\.nzonscreen\.com/title/(?P<id>[^/?#]+)/?(?!series)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://www.nzonscreen.com/title/shoop-shoop-diddy-wop-cumma-cumma-wang-dang-1982',
|
'url': 'https://www.nzonscreen.com/title/shoop-shoop-diddy-wop-cumma-cumma-wang-dang-1982',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '726ed6585c6bfb30',
|
'id': '726ed6585c6bfb30',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'format_id': 'hi',
|
'format_id': 'hi',
|
||||||
|
'height': 480,
|
||||||
|
'width': 640,
|
||||||
'display_id': 'shoop-shoop-diddy-wop-cumma-cumma-wang-dang-1982',
|
'display_id': 'shoop-shoop-diddy-wop-cumma-cumma-wang-dang-1982',
|
||||||
'title': 'Monte Video - "Shoop Shoop, Diddy Wop"',
|
'title': 'Monte Video - "Shoop Shoop, Diddy Wop"',
|
||||||
'description': 'Monte Video - "Shoop Shoop, Diddy Wop"',
|
'description': 'Monte Video - "Shoop Shoop, Diddy Wop"',
|
||||||
'alt_title': 'Shoop Shoop Diddy Wop Cumma Cumma Wang Dang | Music Video',
|
'alt_title': 'Shoop Shoop Diddy Wop Cumma Cumma Wang Dang',
|
||||||
'thumbnail': r're:https://www\.nzonscreen\.com/content/images/.+\.jpg',
|
'thumbnail': r're:https://www\.nzonscreen\.com/content/images/.+\.jpg',
|
||||||
'duration': 158,
|
'duration': 158,
|
||||||
},
|
},
|
||||||
|
@ -31,10 +33,12 @@ class NZOnScreenIE(InfoExtractor):
|
||||||
'id': '3dbe709ff03c36f1',
|
'id': '3dbe709ff03c36f1',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'format_id': 'hi',
|
'format_id': 'hi',
|
||||||
|
'height': 480,
|
||||||
|
'width': 640,
|
||||||
'display_id': 'shes-a-mod-1964',
|
'display_id': 'shes-a-mod-1964',
|
||||||
'title': 'Ray Columbus - \'She\'s A Mod\'',
|
'title': 'Ray Columbus - \'She\'s A Mod\'',
|
||||||
'description': 'Ray Columbus - \'She\'s A Mod\'',
|
'description': 'Ray Columbus - \'She\'s A Mod\'',
|
||||||
'alt_title': 'She\'s a Mod | Music Video',
|
'alt_title': 'She\'s a Mod',
|
||||||
'thumbnail': r're:https://www\.nzonscreen\.com/content/images/.+\.jpg',
|
'thumbnail': r're:https://www\.nzonscreen\.com/content/images/.+\.jpg',
|
||||||
'duration': 130,
|
'duration': 130,
|
||||||
},
|
},
|
||||||
|
@ -45,49 +49,109 @@ class NZOnScreenIE(InfoExtractor):
|
||||||
'id': 'f86342544385ad8a',
|
'id': 'f86342544385ad8a',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'format_id': 'hi',
|
'format_id': 'hi',
|
||||||
|
'height': 540,
|
||||||
|
'width': 718,
|
||||||
'display_id': 'puha-and-pakeha-1968',
|
'display_id': 'puha-and-pakeha-1968',
|
||||||
'title': 'Looking At New Zealand - Puha and Pakeha',
|
'title': 'Looking At New Zealand - Puha and Pakeha',
|
||||||
'alt_title': 'Looking at New Zealand - \'Pūhā and Pākehā\' | Television',
|
'alt_title': 'Looking at New Zealand - \'Pūhā and Pākehā\'',
|
||||||
'description': 'An excerpt from this television programme.',
|
'description': 'An excerpt from this television programme.',
|
||||||
'duration': 212,
|
'duration': 212,
|
||||||
'thumbnail': r're:https://www\.nzonscreen\.com/content/images/.+\.jpg',
|
'thumbnail': r're:https://www\.nzonscreen\.com/content/images/.+\.jpg',
|
||||||
},
|
},
|
||||||
'params': {'skip_download': 'm3u8'},
|
'params': {'skip_download': 'm3u8'},
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.nzonscreen.com/title/flatmates-episode-one-1997',
|
||||||
|
'playlist': [{
|
||||||
|
'info_dict': {
|
||||||
|
'id': '8f4941d243e42210',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'format_id': 'hd',
|
||||||
|
'height': 574,
|
||||||
|
'width': 740,
|
||||||
|
'title': 'Flatmates ep 1',
|
||||||
|
'display_id': 'flatmates-episode-one-1997',
|
||||||
|
'thumbnail': r're:https://www\.nzonscreen\.com/content/images/.+\.jpg',
|
||||||
|
'duration': 1355.0,
|
||||||
|
'description': 'Episode 1',
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'flatmates-episode-one-1997',
|
||||||
|
'title': 'Flatmates - 1, First Episode',
|
||||||
|
},
|
||||||
|
'playlist_count': 5,
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.nzonscreen.com/title/reluctant-hero-2008',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '847f5c91af65d44b',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'format_id': 'hi',
|
||||||
|
'height': 360,
|
||||||
|
'width': 640,
|
||||||
|
'subtitles': {
|
||||||
|
'en': [{'ext': 'SRT', 'data': 'md5:c2469f71020a32e55e228b532ded908f'}],
|
||||||
|
},
|
||||||
|
'title': 'Reluctant Hero (clip 1)',
|
||||||
|
'description': 'Part one of four from this full length documentary.',
|
||||||
|
'display_id': 'reluctant-hero-2008',
|
||||||
|
'duration': 1108.0,
|
||||||
|
'thumbnail': r're:https://www\.nzonscreen\.com/content/images/.+\.jpg',
|
||||||
|
},
|
||||||
|
'params': {'writesubtitles': True},
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _extract_formats(self, playlist):
|
def _extract_formats(self, playlist):
|
||||||
|
formats = []
|
||||||
for quality, (id_, url) in enumerate(traverse_obj(
|
for quality, (id_, url) in enumerate(traverse_obj(
|
||||||
playlist, ('h264', {'lo': 'lo_res', 'hi': 'hi_res'}), expected_type=url_or_none).items()):
|
playlist, ('h264', {'lo': 'lo_res', 'hi': 'hi_res', 'hd': 'hd_res'}),
|
||||||
yield {
|
expected_type=url_or_none).items()):
|
||||||
'url': url,
|
if traverse_obj(playlist, ('h264', f'{id_}_res_mb', {float_or_none})):
|
||||||
'format_id': id_,
|
formats.append({
|
||||||
'ext': 'mp4',
|
'url': url,
|
||||||
'quality': quality,
|
'format_id': id_,
|
||||||
'height': int_or_none(playlist.get('height')) if id_ == 'hi' else None,
|
'ext': 'mp4',
|
||||||
'width': int_or_none(playlist.get('width')) if id_ == 'hi' else None,
|
'quality': quality,
|
||||||
'filesize_approx': float_or_none(traverse_obj(playlist, ('h264', f'{id_}_res_mb')), invscale=1024**2),
|
'filesize_approx': float_or_none(traverse_obj(
|
||||||
}
|
playlist, ('h264', f'{id_}_res_mb')), invscale=1024**2),
|
||||||
|
})
|
||||||
|
if formats:
|
||||||
|
formats[-1].update(traverse_obj(playlist, {
|
||||||
|
'height': ('height', {int_or_none}),
|
||||||
|
'width': ('width', {int_or_none}),
|
||||||
|
}))
|
||||||
|
return formats
|
||||||
|
|
||||||
|
def _get_subtitles(self, playinfo, video_id):
|
||||||
|
if caption := traverse_obj(playinfo, ('h264', 'caption_url')):
|
||||||
|
subtitle, urlh = self._download_webpage_handle(
|
||||||
|
'https://www.nzonscreen.com' + caption, video_id, 'Downloading subtitles')
|
||||||
|
if subtitle:
|
||||||
|
return {'en': [{'ext': urlhandle_detect_ext(urlh), 'data': subtitle}]}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
|
title = strip_or_none((
|
||||||
|
self._html_extract_title(webpage, default=None)
|
||||||
|
or self._og_search_title(webpage)).rsplit('|', 2)[0])
|
||||||
|
playlist = self._download_json(
|
||||||
|
f'https://www.nzonscreen.com/html5/video_data/{video_id}', video_id,
|
||||||
|
'Downloading media data')
|
||||||
|
|
||||||
playlist = self._parse_json(self._html_search_regex(
|
return self.playlist_result([{
|
||||||
r'data-video-config=\'([^\']+)\'', webpage, 'media data'), video_id)
|
'alt_title': title if len(playlist) == 1 else None,
|
||||||
|
|
||||||
return {
|
|
||||||
'id': playlist['uuid'],
|
|
||||||
'display_id': video_id,
|
'display_id': video_id,
|
||||||
'title': strip_or_none(playlist.get('label')),
|
|
||||||
'description': strip_or_none(playlist.get('description')),
|
|
||||||
'alt_title': strip_or_none(remove_end(
|
|
||||||
self._html_extract_title(webpage, default=None) or self._og_search_title(webpage),
|
|
||||||
' | NZ On Screen')),
|
|
||||||
'thumbnail': traverse_obj(playlist, ('thumbnail', 'path')),
|
|
||||||
'duration': float_or_none(playlist.get('duration')),
|
|
||||||
'formats': list(self._extract_formats(playlist)),
|
|
||||||
'http_headers': {
|
'http_headers': {
|
||||||
'Referer': 'https://www.nzonscreen.com/',
|
'Referer': 'https://www.nzonscreen.com/',
|
||||||
'Origin': 'https://www.nzonscreen.com/',
|
'Origin': 'https://www.nzonscreen.com/',
|
||||||
},
|
},
|
||||||
}
|
'subtitles': self.extract_subtitles(playinfo, video_id),
|
||||||
|
**traverse_obj(playinfo, {
|
||||||
|
'formats': {self._extract_formats},
|
||||||
|
'id': 'uuid',
|
||||||
|
'title': ('label', {strip_or_none}),
|
||||||
|
'description': ('description', {strip_or_none}),
|
||||||
|
'thumbnail': ('thumbnail', 'path'),
|
||||||
|
'duration': ('duration', {float_or_none}),
|
||||||
|
}),
|
||||||
|
} for playinfo in playlist], video_id, title)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user