mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-08-15 00:48:28 +00:00
Fixings
This commit is contained in:
parent
23c658b9cb
commit
1acb92f3aa
@ -1,7 +1,9 @@
|
|||||||
import functools
|
import functools
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from .. import float_or_none
|
||||||
from ..networking.exceptions import HTTPError
|
from ..networking.exceptions import HTTPError
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
@ -16,6 +18,7 @@
|
|||||||
url_or_none,
|
url_or_none,
|
||||||
urlencode_postdata,
|
urlencode_postdata,
|
||||||
urljoin,
|
urljoin,
|
||||||
|
parse_resolution,
|
||||||
)
|
)
|
||||||
from ..utils.traversal import traverse_obj
|
from ..utils.traversal import traverse_obj
|
||||||
|
|
||||||
@ -37,14 +40,15 @@ class NewgroundsIE(InfoExtractor):
|
|||||||
'view_count': int,
|
'view_count': int,
|
||||||
'description': 'md5:b8b3c2958875189f07d8e313462e8c4f',
|
'description': 'md5:b8b3c2958875189f07d8e313462e8c4f',
|
||||||
'age_limit': 0,
|
'age_limit': 0,
|
||||||
|
'average_rating': float,
|
||||||
'thumbnail': r're:^https://aicon\.ngfiles\.com/549/549479\.png',
|
'thumbnail': r're:^https://aicon\.ngfiles\.com/549/549479\.png',
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://www.newgrounds.com/portal/view/1',
|
'url': 'https://www.newgrounds.com/portal/view/1',
|
||||||
'md5': 'fbfb40e2dc765a7e830cb251d370d981',
|
'md5': '7475546f1d8611052fe7204de5cbb102',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '1',
|
'id': '1',
|
||||||
'ext': 'mp4',
|
'ext': 'swf',
|
||||||
'title': 'Scrotum 1',
|
'title': 'Scrotum 1',
|
||||||
'uploader': 'Brian-Beaton',
|
'uploader': 'Brian-Beaton',
|
||||||
'timestamp': 955078533,
|
'timestamp': 955078533,
|
||||||
@ -52,6 +56,7 @@ class NewgroundsIE(InfoExtractor):
|
|||||||
'view_count': int,
|
'view_count': int,
|
||||||
'description': 'Scrotum plays "catch."',
|
'description': 'Scrotum plays "catch."',
|
||||||
'age_limit': 17,
|
'age_limit': 17,
|
||||||
|
'average_rating': float,
|
||||||
'thumbnail': r're:^https://picon\.ngfiles\.com/0/flash_1_card\.png',
|
'thumbnail': r're:^https://picon\.ngfiles\.com/0/flash_1_card\.png',
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
@ -65,8 +70,9 @@ class NewgroundsIE(InfoExtractor):
|
|||||||
'timestamp': 1487983183,
|
'timestamp': 1487983183,
|
||||||
'upload_date': '20170225',
|
'upload_date': '20170225',
|
||||||
'view_count': int,
|
'view_count': int,
|
||||||
'description': 'md5:aff9b330ec2e78ed93b1ad6d017accc6',
|
'description': str,
|
||||||
'age_limit': 17,
|
'age_limit': 17,
|
||||||
|
'average_rating': float,
|
||||||
'thumbnail': r're:^https://picon\.ngfiles\.com/689000/flash_689400_card\.png',
|
'thumbnail': r're:^https://picon\.ngfiles\.com/689000/flash_689400_card\.png',
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
@ -74,32 +80,18 @@ class NewgroundsIE(InfoExtractor):
|
|||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://www.newgrounds.com/portal/view/297383',
|
'url': 'https://www.newgrounds.com/portal/view/297383',
|
||||||
'md5': '2c11f5fd8cb6b433a63c89ba3141436c',
|
|
||||||
'info_dict': {
|
|
||||||
'id': '297383',
|
|
||||||
'ext': 'mp4',
|
|
||||||
'title': 'Metal Gear Awesome',
|
|
||||||
'uploader': 'Egoraptor',
|
|
||||||
'timestamp': 1140681292,
|
|
||||||
'upload_date': '20060223',
|
|
||||||
'view_count': int,
|
|
||||||
'description': 'md5:9246c181614e23754571995104da92e0',
|
|
||||||
'age_limit': 13,
|
|
||||||
'thumbnail': r're:^https://picon\.ngfiles\.com/297000/flash_297383_card\.png',
|
|
||||||
},
|
|
||||||
}, {
|
|
||||||
'url': 'https://www.newgrounds.com/portal/view/297383/format/flash',
|
|
||||||
'md5': '5d05585a9a0caca059f5abfbd3865524',
|
'md5': '5d05585a9a0caca059f5abfbd3865524',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '297383',
|
'id': '297383',
|
||||||
'ext': 'swf',
|
'ext': 'swf',
|
||||||
'title': 'Metal Gear Awesome',
|
'title': 'Metal Gear Awesome',
|
||||||
'description': 'Metal Gear Awesome',
|
'description': str,
|
||||||
'uploader': 'Egoraptor',
|
'uploader': 'Egoraptor',
|
||||||
'upload_date': '20060223',
|
'upload_date': '20060223',
|
||||||
'timestamp': 1140681292,
|
'timestamp': 1140681292,
|
||||||
'view_count': int,
|
'view_count': int,
|
||||||
'age_limit': 13,
|
'age_limit': 13,
|
||||||
|
'average_rating': float,
|
||||||
'thumbnail': r're:^https://picon\.ngfiles\.com/297000/flash_297383_card\.png',
|
'thumbnail': r're:^https://picon\.ngfiles\.com/297000/flash_297383_card\.png',
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
@ -114,6 +106,7 @@ class NewgroundsIE(InfoExtractor):
|
|||||||
'timestamp': 1637611540,
|
'timestamp': 1637611540,
|
||||||
'view_count': int,
|
'view_count': int,
|
||||||
'age_limit': 18,
|
'age_limit': 18,
|
||||||
|
'average_rating': float,
|
||||||
'thumbnail': r're:^https://picon\.ngfiles\.com/823000/flash_823109_card\.png',
|
'thumbnail': r're:^https://picon\.ngfiles\.com/823000/flash_823109_card\.png',
|
||||||
},
|
},
|
||||||
}]
|
}]
|
||||||
@ -170,13 +163,20 @@ def _real_extract(self, url):
|
|||||||
formats = []
|
formats = []
|
||||||
uploader = traverse_obj(json_video, ('author', {str}))
|
uploader = traverse_obj(json_video, ('author', {str}))
|
||||||
for format_id, sources in traverse_obj(json_video, ('sources', {dict.items}, ...)):
|
for format_id, sources in traverse_obj(json_video, ('sources', {dict.items}, ...)):
|
||||||
quality = int_or_none(format_id[:-1])
|
quality = parse_resolution(format_id)['height']
|
||||||
formats.extend({
|
for url in traverse_obj(sources, (..., 'src', {url_or_none})):
|
||||||
'format_id': format_id,
|
formats.append({
|
||||||
'quality': quality,
|
'format_id': format_id,
|
||||||
'url': url,
|
'quality': quality,
|
||||||
} for url in traverse_obj(sources, (..., 'src', {url_or_none})))
|
'url': url,
|
||||||
|
})
|
||||||
|
raw_url = re.sub(r'\?\d+', '', url)
|
||||||
|
if raw_url != url:
|
||||||
|
formats.append({
|
||||||
|
'format_id': 's' + format_id,
|
||||||
|
'quality': quality + 1,
|
||||||
|
'url': raw_url,
|
||||||
|
})
|
||||||
if not uploader:
|
if not uploader:
|
||||||
uploader = self._html_search_regex(
|
uploader = self._html_search_regex(
|
||||||
(r'(?s)<h4[^>]*>(.+?)</h4>.*?<em>\s*(?:Author|Artist)\s*</em>',
|
(r'(?s)<h4[^>]*>(.+?)</h4>.*?<em>\s*(?:Author|Artist)\s*</em>',
|
||||||
@ -209,6 +209,8 @@ def _real_extract(self, url):
|
|||||||
or self._og_search_description(webpage)),
|
or self._og_search_description(webpage)),
|
||||||
'age_limit': self._AGE_LIMIT.get(self._html_search_regex(
|
'age_limit': self._AGE_LIMIT.get(self._html_search_regex(
|
||||||
r'<h2\s+class=["\']rated-([etma])["\']', webpage, 'age_limit', default='e')),
|
r'<h2\s+class=["\']rated-([etma])["\']', webpage, 'age_limit', default='e')),
|
||||||
|
'average_rating': float_or_none(self._html_search_regex(
|
||||||
|
r'<span\s+id=["\']score_number["\'][^>]*>([^<]+)', webpage, 'score_number', default=None)),
|
||||||
'view_count': parse_count(self._html_search_regex(
|
'view_count': parse_count(self._html_search_regex(
|
||||||
r'(?s)<dt>\s*(?:Views|Listens)\s*</dt>\s*<dd>([\d\.,]+)</dd>',
|
r'(?s)<dt>\s*(?:Views|Listens)\s*</dt>\s*<dd>([\d\.,]+)</dd>',
|
||||||
webpage, 'view count', default=None)),
|
webpage, 'view count', default=None)),
|
||||||
|
Loading…
Reference in New Issue
Block a user