Skip to content

Commit

Permalink
[bot] AutoMerging: merge all upstream's changes:
Browse files Browse the repository at this point in the history
* https://github.com/ytdl-org/youtube-dl:
  [compat] add compat_SimpleCookie
  [extractor/common] keep support for non standard JSON-LD VideoObject author values
  [vimeo] improve extraction(closes ytdl-org#28591)
  [extractor/common] fix JSON-LD VideoObject author extraction
  [youku] Update ccode(closes ytdl-org#17852, closes ytdl-org#28447, closes ytdl-org#28460) (ytdl-org#28648)
  • Loading branch information
github-actions[bot] committed Apr 4, 2021
2 parents 5dd4f94 + 162bf9e commit b4f69f4
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 147 deletions.
9 changes: 9 additions & 0 deletions youtube_dl/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ def __init__(self, version, name, value, *args, **kwargs):
except ImportError: # Python 2
import Cookie as compat_cookies

if sys.version_info[0] == 2:
class compat_SimpleCookie(compat_cookies.SimpleCookie):
def load(self, rawdata):
if isinstance(rawdata, unicode):
rawdata = str(rawdata)
return super(compat_SimpleCookie, self).load(rawdata)
else:
compat_SimpleCookie = compat_cookies.SimpleCookie

try:
import html.entities as compat_html_entities
except ImportError: # Python 2
Expand Down
16 changes: 9 additions & 7 deletions youtube_dl/extractor/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

from ..compat import (
compat_cookiejar_Cookie,
compat_cookies,
compat_etree_Element,
compat_etree_fromstring,
compat_getpass,
compat_integer_types,
compat_http_client,
compat_os_name,
compat_SimpleCookie,
compat_str,
compat_urllib_error,
compat_urllib_parse_unquote,
Expand Down Expand Up @@ -1275,14 +1275,19 @@ def extract_interaction_statistic(e):

def extract_video_object(e):
assert e['@type'] == 'VideoObject'
author = e.get('author')
info.update({
'url': url_or_none(e.get('contentUrl')),
'title': unescapeHTML(e.get('name')),
'description': unescapeHTML(e.get('description')),
'thumbnail': url_or_none(e.get('thumbnailUrl') or e.get('thumbnailURL')),
'duration': parse_duration(e.get('duration')),
'timestamp': unified_timestamp(e.get('uploadDate')),
'uploader': str_or_none(e.get('author')),
# author can be an instance of 'Organization' or 'Person' types.
# both types can have 'name' property(inherited from 'Thing' type). [1]
# however some websites are using 'Text' type instead.
# 1. https://schema.org/VideoObject
'uploader': author.get('name') if isinstance(author, dict) else author if isinstance(author, compat_str) else None,
'filesize': float_or_none(e.get('contentSize')),
'tbr': int_or_none(e.get('bitrate')),
'width': int_or_none(e.get('width')),
Expand Down Expand Up @@ -2896,13 +2901,10 @@ def _set_cookie(self, domain, name, value, expire_time=None, port=None,
self._downloader.cookiejar.set_cookie(cookie)

def _get_cookies(self, url):
""" Return a compat_cookies.SimpleCookie with the cookies for the url """
""" Return a compat_SimpleCookie with the cookies for the url """
req = sanitized_Request(url)
self._downloader.cookiejar.add_cookie_header(req)
cookie = req.get_header('Cookie')
if cookie and sys.version_info[0] == 2:
cookie = str(cookie)
return compat_cookies.SimpleCookie(cookie)
return compat_SimpleCookie(req.get_header('Cookie'))

def _apply_first_set_cookie_header(self, url_handle, cookie):
"""
Expand Down
Loading

0 comments on commit b4f69f4

Please sign in to comment.