mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-10-01 14:51:25 +02:00
Compare commits
No commits in common. "173930869fe2f1c5cff3c38c486d0418d415c5d6" and "2a94707d3b3ecf87e3e83dadc133f53170750c65" have entirely different histories.
173930869f
...
2a94707d3b
|
@ -1335,8 +1335,8 @@ from .ntvru import NTVRuIE
|
|||
from .nubilesporn import NubilesPornIE
|
||||
from .nytimes import (
|
||||
NYTimesArticleIE,
|
||||
NYTimesCookingIE,
|
||||
NYTimesCookingGuidesIE,
|
||||
NYTimesCookingReceipesIE,
|
||||
)
|
||||
from .nuvid import NuvidIE
|
||||
from .nzherald import NZHeraldIE
|
||||
|
|
|
@ -235,8 +235,7 @@ class NYTimesArticleIE(NYTimesBaseIE):
|
|||
}
|
||||
|
||||
|
||||
class NYTimesCookingIE(InfoExtractor):
|
||||
IE_NAME = 'NYTimesCookingRecipes'
|
||||
class NYTimesCookingReceipesIE(InfoExtractor):
|
||||
_VALID_URL = r'https?://cooking\.nytimes\.com/recipes/(?P<id>\d+)'
|
||||
_TESTS = [{
|
||||
'url': 'https://cooking.nytimes.com/recipes/1017817-cranberry-curd-tart',
|
||||
|
@ -355,19 +354,96 @@ class NYTimesCookingGuidesIE(NYTimesBaseIE):
|
|||
'playlist_count': 8,
|
||||
}]
|
||||
|
||||
_TOKEN = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuNIzKBOFB77aT/jN/FQ+/QVKWq5V1ka1AYmCR9hstz1pGNPH5ajOU9gAqta0T89iPnhjwla+3oec/Z3kGjxbpv6miQXufHFq3u2RC6HyU458cLat5kVPSOQCe3VVB5NRpOlRuwKHqn0txfxnwSSj8mqzstR997d3gKB//RO9zE16y3PoWlDQXkASngNJEWvL19iob/xwAkfEWCjyRILWFY0JYX3AvLMSbq7wsqOCE5srJpo7rRU32zsByhsp1D5W9OYqqwDmflsgCEQy2vqTsJjrJohuNg+urMXNNZ7Y3naMoqttsGDrWVxtPBafKMI8pM2ReNZBbGQsQXRzQNo7+QIDAQAB'
|
||||
_TOKEN = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuNIzKBOFB77aT/jN/FQ+/QVKWq5V1ka1AYmCR9hstz1pGNPH5ajOU9gAqta0T89iPnhjwla+3oec/Z3kGjxbpv6miQXufHFq3u2RC6HyU458cLat5kVPSOQCe3VVB5NRpOlRuwKHqn0txfxnwSSj8mqzstR997d3gKB//RO9zE16y3PoWlDQXkASngNJEWvL19iob/xwAkfEWCjyRILWFY0JYX3AvLMSbq7wsqOCE5srJpo7rRU32zsByhsp1D5W9OYqqwDmflsgCEQy2vqTsJjrJohuNg+urMXNNZ7Y3naMoqttsGDrWVxtPBafKMI8pM2ReNZBbGQsQXRzQNo7+QIDAQAB"
|
||||
_DNS_UUID = '36dd619a-56dc-595b-9e09-37f4152c7b5d' # uuid -v5 ns:DNS scoop.nyt.net
|
||||
_GRAPHQL_QUERY = '''query VideoQuery($id: String!) {
|
||||
video(id: $id) {
|
||||
... on Video {
|
||||
advertisingProperties {
|
||||
sensitivity
|
||||
sponsored
|
||||
}
|
||||
bylines {
|
||||
renderedRepresentation
|
||||
}
|
||||
contentSeries
|
||||
cues {
|
||||
name
|
||||
type
|
||||
timeIn
|
||||
timeOut
|
||||
}
|
||||
duration
|
||||
embedded
|
||||
headline {
|
||||
default
|
||||
}
|
||||
is360
|
||||
isLive
|
||||
liveUrls
|
||||
playlist {
|
||||
headline {
|
||||
default
|
||||
}
|
||||
promotionalHeadline
|
||||
url
|
||||
sourceId
|
||||
section {
|
||||
displayName
|
||||
}
|
||||
videos(first: 20) {
|
||||
edges @filterEmpty {
|
||||
node {
|
||||
advertisingProperties {
|
||||
sensitivity
|
||||
sponsored
|
||||
}
|
||||
id
|
||||
sourceId
|
||||
duration
|
||||
section {
|
||||
id
|
||||
name
|
||||
}
|
||||
headline {
|
||||
default
|
||||
}
|
||||
renditions {
|
||||
url
|
||||
type
|
||||
}
|
||||
url
|
||||
promotionalMedia {
|
||||
... on Image {
|
||||
crops(
|
||||
cropNames: [SMALL_SQUARE, MEDIUM_SQUARE, SIXTEEN_BY_NINE]
|
||||
) {
|
||||
renditions {
|
||||
name
|
||||
width
|
||||
height
|
||||
url
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
promotionalHeadline
|
||||
promotionalMedia {
|
||||
... on Image {
|
||||
crops {
|
||||
crops(
|
||||
cropNames: [
|
||||
SMALL_SQUARE
|
||||
MEDIUM_SQUARE
|
||||
SIXTEEN_BY_NINE
|
||||
THREE_BY_TWO
|
||||
TWO_BY_THREE
|
||||
FLEXIBLE
|
||||
]
|
||||
) {
|
||||
name
|
||||
renditions {
|
||||
name
|
||||
|
@ -378,6 +454,14 @@ class NYTimesCookingGuidesIE(NYTimesBaseIE):
|
|||
}
|
||||
}
|
||||
}
|
||||
promotionalSummary
|
||||
related {
|
||||
... on Article {
|
||||
promotionalHeadline
|
||||
url
|
||||
sourceId
|
||||
}
|
||||
}
|
||||
renditions {
|
||||
type
|
||||
width
|
||||
|
@ -385,7 +469,22 @@ class NYTimesCookingGuidesIE(NYTimesBaseIE):
|
|||
url
|
||||
bitrate
|
||||
}
|
||||
section {
|
||||
name
|
||||
}
|
||||
shortUrl
|
||||
sourceId
|
||||
subsection {
|
||||
name
|
||||
}
|
||||
summary
|
||||
timesTags {
|
||||
__typename
|
||||
displayName
|
||||
isAdvertisingBrandSensitive
|
||||
vernacular
|
||||
}
|
||||
url
|
||||
}
|
||||
}
|
||||
}'''
|
||||
|
@ -410,7 +509,6 @@ class NYTimesCookingGuidesIE(NYTimesBaseIE):
|
|||
if not url_or_none(image_url):
|
||||
continue
|
||||
thumbnails.append({
|
||||
'name': image.get('name'),
|
||||
'url': image_url,
|
||||
'width': int_or_none(image.get('width')),
|
||||
'height': int_or_none(image.get('height')),
|
||||
|
@ -428,28 +526,28 @@ class NYTimesCookingGuidesIE(NYTimesBaseIE):
|
|||
})
|
||||
return entries
|
||||
|
||||
def _json_from_graphql(self, media_id):
|
||||
def _json_from_graphql(self, id):
|
||||
# reference: `id-to-uri.js`
|
||||
namespace = uuid.UUID(self._DNS_UUID)
|
||||
video_uuid = uuid.uuid5(namespace, 'video')
|
||||
media_uuid = uuid.uuid5(video_uuid, media_id)
|
||||
media_uuid = uuid.uuid5(video_uuid, id)
|
||||
|
||||
payload = {
|
||||
'query': self._GRAPHQL_QUERY,
|
||||
'variables': {'id': f'nyt://video/{media_uuid}'}
|
||||
"query": self._GRAPHQL_QUERY,
|
||||
"variables": {"id": f"nyt://video/{media_uuid}"}
|
||||
}
|
||||
|
||||
headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'Nyt-App-Type': 'vhs',
|
||||
'Nyt-App-Version': 'v3.52.21',
|
||||
'Nyt-Token': self._TOKEN,
|
||||
'Origin': 'https://cooking.nytimes.com',
|
||||
'Referer': 'https://www.google.com/',
|
||||
"Content-Type": "application/json",
|
||||
"Nyt-App-Type": "vhs",
|
||||
"Nyt-App-Version": "v3.52.21",
|
||||
"Nyt-Token": self._TOKEN,
|
||||
"Origin": "https://cooking.nytimes.com",
|
||||
"Referer": "https://www.google.com/",
|
||||
}
|
||||
|
||||
return self._download_json(
|
||||
self._GRAPHQL_API, id, note='Downloading json from GRAPHQL API',
|
||||
self._GRAPHQL_API, id, note="Downloading json from GRAPHQL API",
|
||||
data=json.dumps(payload, separators=(',', ':')).encode(), headers=headers, fatal=False)
|
||||
|
||||
def _real_extract(self, url):
|
||||
|
@ -463,7 +561,7 @@ class NYTimesCookingGuidesIE(NYTimesBaseIE):
|
|||
title = self._html_search_meta(['og:title', 'twitter:title'], webpage)
|
||||
description = self._html_search_meta(['og:description', 'twitter:description'], webpage)
|
||||
creator = self._search_regex(
|
||||
r'<span itemprop="author">([^<]+)</span></p>', webpage, 'author', default=None)
|
||||
r'<span itemprop="author">(.+)</span></p>', webpage, 'author', default=None)
|
||||
|
||||
if media_items:
|
||||
media_items.append(lead_video_id)
|
||||
|
|
Loading…
Reference in New Issue
Block a user