mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-07 03:37:17 +08:00
commit
12cf3f125f
6
.github/ISSUE_TEMPLATE/1_broken_site.md
vendored
6
.github/ISSUE_TEMPLATE/1_broken_site.md
vendored
@ -18,7 +18,7 @@ title: ''
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Carefully read and work through this check list in order to prevent the most common mistakes and misuse of youtube-dl:
|
Carefully read and work through this check list in order to prevent the most common mistakes and misuse of youtube-dl:
|
||||||
- First of, make sure you are using the latest version of youtube-dl. Run `youtube-dl --version` and ensure your version is 2020.03.24. If it's not, see https://yt-dl.org/update on how to update. Issues with outdated version will be REJECTED.
|
- First of, make sure you are using the latest version of youtube-dl. Run `youtube-dl --version` and ensure your version is 2020.05.03. If it's not, see https://yt-dl.org/update on how to update. Issues with outdated version will be REJECTED.
|
||||||
- Make sure that all provided video/audio/playlist URLs (if any) are alive and playable in a browser.
|
- Make sure that all provided video/audio/playlist URLs (if any) are alive and playable in a browser.
|
||||||
- Make sure that all URLs and arguments with special characters are properly quoted or escaped as explained in http://yt-dl.org/escape.
|
- Make sure that all URLs and arguments with special characters are properly quoted or escaped as explained in http://yt-dl.org/escape.
|
||||||
- Search the bugtracker for similar issues: http://yt-dl.org/search-issues. DO NOT post duplicates.
|
- Search the bugtracker for similar issues: http://yt-dl.org/search-issues. DO NOT post duplicates.
|
||||||
@ -26,7 +26,7 @@ Carefully read and work through this check list in order to prevent the most com
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
- [ ] I'm reporting a broken site support
|
- [ ] I'm reporting a broken site support
|
||||||
- [ ] I've verified that I'm running youtube-dl version **2020.03.24**
|
- [ ] I've verified that I'm running youtube-dl version **2020.05.03**
|
||||||
- [ ] I've checked that all provided URLs are alive and playable in a browser
|
- [ ] I've checked that all provided URLs are alive and playable in a browser
|
||||||
- [ ] I've checked that all URLs and arguments with special characters are properly quoted or escaped
|
- [ ] I've checked that all URLs and arguments with special characters are properly quoted or escaped
|
||||||
- [ ] I've searched the bugtracker for similar issues including closed ones
|
- [ ] I've searched the bugtracker for similar issues including closed ones
|
||||||
@ -41,7 +41,7 @@ Add the `-v` flag to your command line you run youtube-dl with (`youtube-dl -v <
|
|||||||
[debug] User config: []
|
[debug] User config: []
|
||||||
[debug] Command-line args: [u'-v', u'http://www.youtube.com/watch?v=BaW_jenozKcj']
|
[debug] Command-line args: [u'-v', u'http://www.youtube.com/watch?v=BaW_jenozKcj']
|
||||||
[debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251
|
[debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251
|
||||||
[debug] youtube-dl version 2020.03.24
|
[debug] youtube-dl version 2020.05.03
|
||||||
[debug] Python version 2.7.11 - Windows-2003Server-5.2.3790-SP2
|
[debug] Python version 2.7.11 - Windows-2003Server-5.2.3790-SP2
|
||||||
[debug] exe versions: ffmpeg N-75573-g1d0487f, ffprobe N-75573-g1d0487f, rtmpdump 2.4
|
[debug] exe versions: ffmpeg N-75573-g1d0487f, ffprobe N-75573-g1d0487f, rtmpdump 2.4
|
||||||
[debug] Proxy map: {}
|
[debug] Proxy map: {}
|
||||||
|
@ -19,7 +19,7 @@ labels: 'site-support-request'
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Carefully read and work through this check list in order to prevent the most common mistakes and misuse of youtube-dl:
|
Carefully read and work through this check list in order to prevent the most common mistakes and misuse of youtube-dl:
|
||||||
- First of, make sure you are using the latest version of youtube-dl. Run `youtube-dl --version` and ensure your version is 2020.03.24. If it's not, see https://yt-dl.org/update on how to update. Issues with outdated version will be REJECTED.
|
- First of, make sure you are using the latest version of youtube-dl. Run `youtube-dl --version` and ensure your version is 2020.05.03. If it's not, see https://yt-dl.org/update on how to update. Issues with outdated version will be REJECTED.
|
||||||
- Make sure that all provided video/audio/playlist URLs (if any) are alive and playable in a browser.
|
- Make sure that all provided video/audio/playlist URLs (if any) are alive and playable in a browser.
|
||||||
- Make sure that site you are requesting is not dedicated to copyright infringement, see https://yt-dl.org/copyright-infringement. youtube-dl does not support such sites. In order for site support request to be accepted all provided example URLs should not violate any copyrights.
|
- Make sure that site you are requesting is not dedicated to copyright infringement, see https://yt-dl.org/copyright-infringement. youtube-dl does not support such sites. In order for site support request to be accepted all provided example URLs should not violate any copyrights.
|
||||||
- Search the bugtracker for similar site support requests: http://yt-dl.org/search-issues. DO NOT post duplicates.
|
- Search the bugtracker for similar site support requests: http://yt-dl.org/search-issues. DO NOT post duplicates.
|
||||||
@ -27,7 +27,7 @@ Carefully read and work through this check list in order to prevent the most com
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
- [ ] I'm reporting a new site support request
|
- [ ] I'm reporting a new site support request
|
||||||
- [ ] I've verified that I'm running youtube-dl version **2020.03.24**
|
- [ ] I've verified that I'm running youtube-dl version **2020.05.03**
|
||||||
- [ ] I've checked that all provided URLs are alive and playable in a browser
|
- [ ] I've checked that all provided URLs are alive and playable in a browser
|
||||||
- [ ] I've checked that none of provided URLs violate any copyrights
|
- [ ] I've checked that none of provided URLs violate any copyrights
|
||||||
- [ ] I've searched the bugtracker for similar site support requests including closed ones
|
- [ ] I've searched the bugtracker for similar site support requests including closed ones
|
||||||
|
@ -18,13 +18,13 @@ title: ''
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Carefully read and work through this check list in order to prevent the most common mistakes and misuse of youtube-dl:
|
Carefully read and work through this check list in order to prevent the most common mistakes and misuse of youtube-dl:
|
||||||
- First of, make sure you are using the latest version of youtube-dl. Run `youtube-dl --version` and ensure your version is 2020.03.24. If it's not, see https://yt-dl.org/update on how to update. Issues with outdated version will be REJECTED.
|
- First of, make sure you are using the latest version of youtube-dl. Run `youtube-dl --version` and ensure your version is 2020.05.03. If it's not, see https://yt-dl.org/update on how to update. Issues with outdated version will be REJECTED.
|
||||||
- Search the bugtracker for similar site feature requests: http://yt-dl.org/search-issues. DO NOT post duplicates.
|
- Search the bugtracker for similar site feature requests: http://yt-dl.org/search-issues. DO NOT post duplicates.
|
||||||
- Finally, put x into all relevant boxes (like this [x])
|
- Finally, put x into all relevant boxes (like this [x])
|
||||||
-->
|
-->
|
||||||
|
|
||||||
- [ ] I'm reporting a site feature request
|
- [ ] I'm reporting a site feature request
|
||||||
- [ ] I've verified that I'm running youtube-dl version **2020.03.24**
|
- [ ] I've verified that I'm running youtube-dl version **2020.05.03**
|
||||||
- [ ] I've searched the bugtracker for similar site feature requests including closed ones
|
- [ ] I've searched the bugtracker for similar site feature requests including closed ones
|
||||||
|
|
||||||
|
|
||||||
|
6
.github/ISSUE_TEMPLATE/4_bug_report.md
vendored
6
.github/ISSUE_TEMPLATE/4_bug_report.md
vendored
@ -18,7 +18,7 @@ title: ''
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Carefully read and work through this check list in order to prevent the most common mistakes and misuse of youtube-dl:
|
Carefully read and work through this check list in order to prevent the most common mistakes and misuse of youtube-dl:
|
||||||
- First of, make sure you are using the latest version of youtube-dl. Run `youtube-dl --version` and ensure your version is 2020.03.24. If it's not, see https://yt-dl.org/update on how to update. Issues with outdated version will be REJECTED.
|
- First of, make sure you are using the latest version of youtube-dl. Run `youtube-dl --version` and ensure your version is 2020.05.03. If it's not, see https://yt-dl.org/update on how to update. Issues with outdated version will be REJECTED.
|
||||||
- Make sure that all provided video/audio/playlist URLs (if any) are alive and playable in a browser.
|
- Make sure that all provided video/audio/playlist URLs (if any) are alive and playable in a browser.
|
||||||
- Make sure that all URLs and arguments with special characters are properly quoted or escaped as explained in http://yt-dl.org/escape.
|
- Make sure that all URLs and arguments with special characters are properly quoted or escaped as explained in http://yt-dl.org/escape.
|
||||||
- Search the bugtracker for similar issues: http://yt-dl.org/search-issues. DO NOT post duplicates.
|
- Search the bugtracker for similar issues: http://yt-dl.org/search-issues. DO NOT post duplicates.
|
||||||
@ -27,7 +27,7 @@ Carefully read and work through this check list in order to prevent the most com
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
- [ ] I'm reporting a broken site support issue
|
- [ ] I'm reporting a broken site support issue
|
||||||
- [ ] I've verified that I'm running youtube-dl version **2020.03.24**
|
- [ ] I've verified that I'm running youtube-dl version **2020.05.03**
|
||||||
- [ ] I've checked that all provided URLs are alive and playable in a browser
|
- [ ] I've checked that all provided URLs are alive and playable in a browser
|
||||||
- [ ] I've checked that all URLs and arguments with special characters are properly quoted or escaped
|
- [ ] I've checked that all URLs and arguments with special characters are properly quoted or escaped
|
||||||
- [ ] I've searched the bugtracker for similar bug reports including closed ones
|
- [ ] I've searched the bugtracker for similar bug reports including closed ones
|
||||||
@ -43,7 +43,7 @@ Add the `-v` flag to your command line you run youtube-dl with (`youtube-dl -v <
|
|||||||
[debug] User config: []
|
[debug] User config: []
|
||||||
[debug] Command-line args: [u'-v', u'http://www.youtube.com/watch?v=BaW_jenozKcj']
|
[debug] Command-line args: [u'-v', u'http://www.youtube.com/watch?v=BaW_jenozKcj']
|
||||||
[debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251
|
[debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251
|
||||||
[debug] youtube-dl version 2020.03.24
|
[debug] youtube-dl version 2020.05.03
|
||||||
[debug] Python version 2.7.11 - Windows-2003Server-5.2.3790-SP2
|
[debug] Python version 2.7.11 - Windows-2003Server-5.2.3790-SP2
|
||||||
[debug] exe versions: ffmpeg N-75573-g1d0487f, ffprobe N-75573-g1d0487f, rtmpdump 2.4
|
[debug] exe versions: ffmpeg N-75573-g1d0487f, ffprobe N-75573-g1d0487f, rtmpdump 2.4
|
||||||
[debug] Proxy map: {}
|
[debug] Proxy map: {}
|
||||||
|
4
.github/ISSUE_TEMPLATE/5_feature_request.md
vendored
4
.github/ISSUE_TEMPLATE/5_feature_request.md
vendored
@ -19,13 +19,13 @@ labels: 'request'
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Carefully read and work through this check list in order to prevent the most common mistakes and misuse of youtube-dl:
|
Carefully read and work through this check list in order to prevent the most common mistakes and misuse of youtube-dl:
|
||||||
- First of, make sure you are using the latest version of youtube-dl. Run `youtube-dl --version` and ensure your version is 2020.03.24. If it's not, see https://yt-dl.org/update on how to update. Issues with outdated version will be REJECTED.
|
- First of, make sure you are using the latest version of youtube-dl. Run `youtube-dl --version` and ensure your version is 2020.05.03. If it's not, see https://yt-dl.org/update on how to update. Issues with outdated version will be REJECTED.
|
||||||
- Search the bugtracker for similar feature requests: http://yt-dl.org/search-issues. DO NOT post duplicates.
|
- Search the bugtracker for similar feature requests: http://yt-dl.org/search-issues. DO NOT post duplicates.
|
||||||
- Finally, put x into all relevant boxes (like this [x])
|
- Finally, put x into all relevant boxes (like this [x])
|
||||||
-->
|
-->
|
||||||
|
|
||||||
- [ ] I'm reporting a feature request
|
- [ ] I'm reporting a feature request
|
||||||
- [ ] I've verified that I'm running youtube-dl version **2020.03.24**
|
- [ ] I've verified that I'm running youtube-dl version **2020.05.03**
|
||||||
- [ ] I've searched the bugtracker for similar feature requests including closed ones
|
- [ ] I've searched the bugtracker for similar feature requests including closed ones
|
||||||
|
|
||||||
|
|
||||||
|
34
ChangeLog
34
ChangeLog
@ -1,3 +1,37 @@
|
|||||||
|
version 2020.05.03
|
||||||
|
|
||||||
|
Core
|
||||||
|
+ [extractor/common] Extract multiple JSON-LD entries
|
||||||
|
* [options] Clarify doc on --exec command (#19087, #24883)
|
||||||
|
* [extractor/common] Skip malformed ISM manifest XMLs while extracting
|
||||||
|
ISM formats (#24667)
|
||||||
|
|
||||||
|
Extractors
|
||||||
|
* [crunchyroll] Fix and improve extraction (#25096, #25060)
|
||||||
|
* [youtube] Improve player id extraction
|
||||||
|
* [youtube] Use redirected video id if any (#25063)
|
||||||
|
* [yahoo] Fix GYAO Player extraction and relax URL regular expression
|
||||||
|
(#24178, #24778)
|
||||||
|
* [tvplay] Fix Viafree extraction (#15189, #24473, #24789)
|
||||||
|
* [tenplay] Relax URL regular expression (#25001)
|
||||||
|
+ [prosiebensat1] Extract series metadata
|
||||||
|
* [prosiebensat1] Improve extraction and remove 7tv.de support (#24948)
|
||||||
|
- [prosiebensat1] Remove 7tv.de support (#24948)
|
||||||
|
* [youtube] Fix DRM videos detection (#24736)
|
||||||
|
* [thisoldhouse] Fix video id extraction (#24548, #24549)
|
||||||
|
+ [soundcloud] Extract AAC format (#19173, #24708)
|
||||||
|
* [youtube] Skip broken multifeed videos (#24711)
|
||||||
|
* [nova:embed] Fix extraction (#24700)
|
||||||
|
* [motherless] Fix extraction (#24699)
|
||||||
|
* [twitch:clips] Extend URL regular expression (#24290, #24642)
|
||||||
|
* [tv4] Fix ISM formats extraction (#24667)
|
||||||
|
* [tele5] Fix extraction (#24553)
|
||||||
|
+ [mofosex] Add support for generic embeds (#24633)
|
||||||
|
+ [youporn] Add support for generic embeds
|
||||||
|
+ [spankwire] Add support for generic embeds (#24633)
|
||||||
|
* [spankwire] Fix extraction (#18924, #20648)
|
||||||
|
|
||||||
|
|
||||||
version 2020.03.24
|
version 2020.03.24
|
||||||
|
|
||||||
Core
|
Core
|
||||||
|
@ -434,9 +434,9 @@ Alternatively, refer to the [developer instructions](#developer-instructions) fo
|
|||||||
either the path to the binary or its
|
either the path to the binary or its
|
||||||
containing directory.
|
containing directory.
|
||||||
--exec CMD Execute a command on the file after
|
--exec CMD Execute a command on the file after
|
||||||
downloading, similar to find's -exec
|
downloading and post-processing, similar to
|
||||||
syntax. Example: --exec 'adb push {}
|
find's -exec syntax. Example: --exec 'adb
|
||||||
/sdcard/Music/ && rm {}'
|
push {} /sdcard/Music/ && rm {}'
|
||||||
--convert-subs FORMAT Convert the subtitles to other format
|
--convert-subs FORMAT Convert the subtitles to other format
|
||||||
(currently supported: srt|ass|vtt|lrc)
|
(currently supported: srt|ass|vtt|lrc)
|
||||||
|
|
||||||
|
@ -497,6 +497,7 @@
|
|||||||
- **MNetTV**
|
- **MNetTV**
|
||||||
- **MoeVideo**: LetitBit video services: moevideo.net, playreplay.net and videochart.net
|
- **MoeVideo**: LetitBit video services: moevideo.net, playreplay.net and videochart.net
|
||||||
- **Mofosex**
|
- **Mofosex**
|
||||||
|
- **MofosexEmbed**
|
||||||
- **Mojvideo**
|
- **Mojvideo**
|
||||||
- **Morningstar**: morningstar.com
|
- **Morningstar**: morningstar.com
|
||||||
- **Motherless**
|
- **Motherless**
|
||||||
|
@ -39,6 +39,13 @@ class TestYoutubeDLCookieJar(unittest.TestCase):
|
|||||||
assert_cookie_has_value('HTTPONLY_COOKIE')
|
assert_cookie_has_value('HTTPONLY_COOKIE')
|
||||||
assert_cookie_has_value('JS_ACCESSIBLE_COOKIE')
|
assert_cookie_has_value('JS_ACCESSIBLE_COOKIE')
|
||||||
|
|
||||||
|
def test_malformed_cookies(self):
|
||||||
|
cookiejar = YoutubeDLCookieJar('./test/testdata/cookies/malformed_cookies.txt')
|
||||||
|
cookiejar.load(ignore_discard=True, ignore_expires=True)
|
||||||
|
# Cookies should be empty since all malformed cookie file entries
|
||||||
|
# will be ignored
|
||||||
|
self.assertFalse(cookiejar._cookies)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
@ -74,6 +74,28 @@ _TESTS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class TestPlayerInfo(unittest.TestCase):
|
||||||
|
def test_youtube_extract_player_info(self):
|
||||||
|
PLAYER_URLS = (
|
||||||
|
('https://www.youtube.com/s/player/64dddad9/player_ias.vflset/en_US/base.js', '64dddad9'),
|
||||||
|
# obsolete
|
||||||
|
('https://www.youtube.com/yts/jsbin/player_ias-vfle4-e03/en_US/base.js', 'vfle4-e03'),
|
||||||
|
('https://www.youtube.com/yts/jsbin/player_ias-vfl49f_g4/en_US/base.js', 'vfl49f_g4'),
|
||||||
|
('https://www.youtube.com/yts/jsbin/player_ias-vflCPQUIL/en_US/base.js', 'vflCPQUIL'),
|
||||||
|
('https://www.youtube.com/yts/jsbin/player-vflzQZbt7/en_US/base.js', 'vflzQZbt7'),
|
||||||
|
('https://www.youtube.com/yts/jsbin/player-en_US-vflaxXRn1/base.js', 'vflaxXRn1'),
|
||||||
|
('https://s.ytimg.com/yts/jsbin/html5player-en_US-vflXGBaUN.js', 'vflXGBaUN'),
|
||||||
|
('https://s.ytimg.com/yts/jsbin/html5player-en_US-vflKjOTVq/html5player.js', 'vflKjOTVq'),
|
||||||
|
('http://s.ytimg.com/yt/swfbin/watch_as3-vflrEm9Nq.swf', 'vflrEm9Nq'),
|
||||||
|
('https://s.ytimg.com/yts/swfbin/player-vflenCdZL/watch_as3.swf', 'vflenCdZL'),
|
||||||
|
)
|
||||||
|
for player_url, expected_player_id in PLAYER_URLS:
|
||||||
|
expected_player_type = player_url.split('.')[-1]
|
||||||
|
player_type, player_id = YoutubeIE._extract_player_info(player_url)
|
||||||
|
self.assertEqual(player_type, expected_player_type)
|
||||||
|
self.assertEqual(player_id, expected_player_id)
|
||||||
|
|
||||||
|
|
||||||
class TestSignature(unittest.TestCase):
|
class TestSignature(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
TEST_DIR = os.path.dirname(os.path.abspath(__file__))
|
TEST_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
9
test/testdata/cookies/malformed_cookies.txt
vendored
Normal file
9
test/testdata/cookies/malformed_cookies.txt
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Netscape HTTP Cookie File
|
||||||
|
# http://curl.haxx.se/rfc/cookie_spec.html
|
||||||
|
# This is a generated file! Do not edit.
|
||||||
|
|
||||||
|
# Cookie file entry with invalid number of fields - 6 instead of 7
|
||||||
|
www.foobar.foobar FALSE / FALSE 0 COOKIE
|
||||||
|
|
||||||
|
# Cookie file entry with invalid expires at
|
||||||
|
www.foobar.foobar FALSE / FALSE 1.7976931348623157e+308 COOKIE VALUE
|
@ -57,6 +57,17 @@ try:
|
|||||||
except ImportError: # Python 2
|
except ImportError: # Python 2
|
||||||
import cookielib as compat_cookiejar
|
import cookielib as compat_cookiejar
|
||||||
|
|
||||||
|
if sys.version_info[0] == 2:
|
||||||
|
class compat_cookiejar_Cookie(compat_cookiejar.Cookie):
|
||||||
|
def __init__(self, version, name, value, *args, **kwargs):
|
||||||
|
if isinstance(name, compat_str):
|
||||||
|
name = name.encode()
|
||||||
|
if isinstance(value, compat_str):
|
||||||
|
value = value.encode()
|
||||||
|
compat_cookiejar.Cookie.__init__(self, version, name, value, *args, **kwargs)
|
||||||
|
else:
|
||||||
|
compat_cookiejar_Cookie = compat_cookiejar.Cookie
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import http.cookies as compat_cookies
|
import http.cookies as compat_cookies
|
||||||
except ImportError: # Python 2
|
except ImportError: # Python 2
|
||||||
@ -2987,6 +2998,7 @@ __all__ = [
|
|||||||
'compat_basestring',
|
'compat_basestring',
|
||||||
'compat_chr',
|
'compat_chr',
|
||||||
'compat_cookiejar',
|
'compat_cookiejar',
|
||||||
|
'compat_cookiejar_Cookie',
|
||||||
'compat_cookies',
|
'compat_cookies',
|
||||||
'compat_ctypes_WINFUNCTYPE',
|
'compat_ctypes_WINFUNCTYPE',
|
||||||
'compat_etree_Element',
|
'compat_etree_Element',
|
||||||
|
@ -227,7 +227,7 @@ class HttpFD(FileDownloader):
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
# Download and write
|
# Download and write
|
||||||
data_block = ctx.data.read(block_size if not is_test else min(block_size, data_len - byte_counter))
|
data_block = ctx.data.read(block_size if data_len is None else min(block_size, data_len - byte_counter))
|
||||||
# socket.timeout is a subclass of socket.error but may not have
|
# socket.timeout is a subclass of socket.error but may not have
|
||||||
# errno set
|
# errno set
|
||||||
except socket.timeout as e:
|
except socket.timeout as e:
|
||||||
@ -299,7 +299,7 @@ class HttpFD(FileDownloader):
|
|||||||
'elapsed': now - ctx.start_time,
|
'elapsed': now - ctx.start_time,
|
||||||
})
|
})
|
||||||
|
|
||||||
if is_test and byte_counter == data_len:
|
if data_len is not None and byte_counter == data_len:
|
||||||
break
|
break
|
||||||
|
|
||||||
if not is_test and ctx.chunk_size and ctx.data_len is not None and byte_counter < ctx.data_len:
|
if not is_test and ctx.chunk_size and ctx.data_len is not None and byte_counter < ctx.data_len:
|
||||||
|
@ -15,7 +15,7 @@ import time
|
|||||||
import math
|
import math
|
||||||
|
|
||||||
from ..compat import (
|
from ..compat import (
|
||||||
compat_cookiejar,
|
compat_cookiejar_Cookie,
|
||||||
compat_cookies,
|
compat_cookies,
|
||||||
compat_etree_Element,
|
compat_etree_Element,
|
||||||
compat_etree_fromstring,
|
compat_etree_fromstring,
|
||||||
@ -1182,16 +1182,33 @@ class InfoExtractor(object):
|
|||||||
'twitter card player')
|
'twitter card player')
|
||||||
|
|
||||||
def _search_json_ld(self, html, video_id, expected_type=None, **kwargs):
|
def _search_json_ld(self, html, video_id, expected_type=None, **kwargs):
|
||||||
json_ld = self._search_regex(
|
json_ld_list = list(re.finditer(JSON_LD_RE, html))
|
||||||
JSON_LD_RE, html, 'JSON-LD', group='json_ld', **kwargs)
|
|
||||||
default = kwargs.get('default', NO_DEFAULT)
|
default = kwargs.get('default', NO_DEFAULT)
|
||||||
if not json_ld:
|
|
||||||
return default if default is not NO_DEFAULT else {}
|
|
||||||
# JSON-LD may be malformed and thus `fatal` should be respected.
|
# JSON-LD may be malformed and thus `fatal` should be respected.
|
||||||
# At the same time `default` may be passed that assumes `fatal=False`
|
# At the same time `default` may be passed that assumes `fatal=False`
|
||||||
# for _search_regex. Let's simulate the same behavior here as well.
|
# for _search_regex. Let's simulate the same behavior here as well.
|
||||||
fatal = kwargs.get('fatal', True) if default == NO_DEFAULT else False
|
fatal = kwargs.get('fatal', True) if default == NO_DEFAULT else False
|
||||||
return self._json_ld(json_ld, video_id, fatal=fatal, expected_type=expected_type)
|
json_ld = []
|
||||||
|
for mobj in json_ld_list:
|
||||||
|
json_ld_item = self._parse_json(
|
||||||
|
mobj.group('json_ld'), video_id, fatal=fatal)
|
||||||
|
if not json_ld_item:
|
||||||
|
continue
|
||||||
|
if isinstance(json_ld_item, dict):
|
||||||
|
json_ld.append(json_ld_item)
|
||||||
|
elif isinstance(json_ld_item, (list, tuple)):
|
||||||
|
json_ld.extend(json_ld_item)
|
||||||
|
if json_ld:
|
||||||
|
json_ld = self._json_ld(json_ld, video_id, fatal=fatal, expected_type=expected_type)
|
||||||
|
if json_ld:
|
||||||
|
return json_ld
|
||||||
|
if default is not NO_DEFAULT:
|
||||||
|
return default
|
||||||
|
elif fatal:
|
||||||
|
raise RegexNotFoundError('Unable to extract JSON-LD')
|
||||||
|
else:
|
||||||
|
self._downloader.report_warning('unable to extract JSON-LD %s' % bug_reports_message())
|
||||||
|
return {}
|
||||||
|
|
||||||
def _json_ld(self, json_ld, video_id, fatal=True, expected_type=None):
|
def _json_ld(self, json_ld, video_id, fatal=True, expected_type=None):
|
||||||
if isinstance(json_ld, compat_str):
|
if isinstance(json_ld, compat_str):
|
||||||
@ -1256,10 +1273,10 @@ class InfoExtractor(object):
|
|||||||
extract_interaction_statistic(e)
|
extract_interaction_statistic(e)
|
||||||
|
|
||||||
for e in json_ld:
|
for e in json_ld:
|
||||||
if isinstance(e.get('@context'), compat_str) and re.match(r'^https?://schema.org/?$', e.get('@context')):
|
if '@context' in e:
|
||||||
item_type = e.get('@type')
|
item_type = e.get('@type')
|
||||||
if expected_type is not None and expected_type != item_type:
|
if expected_type is not None and expected_type != item_type:
|
||||||
return info
|
continue
|
||||||
if item_type in ('TVEpisode', 'Episode'):
|
if item_type in ('TVEpisode', 'Episode'):
|
||||||
episode_name = unescapeHTML(e.get('name'))
|
episode_name = unescapeHTML(e.get('name'))
|
||||||
info.update({
|
info.update({
|
||||||
@ -1293,10 +1310,16 @@ class InfoExtractor(object):
|
|||||||
})
|
})
|
||||||
elif item_type == 'VideoObject':
|
elif item_type == 'VideoObject':
|
||||||
extract_video_object(e)
|
extract_video_object(e)
|
||||||
|
if expected_type is None:
|
||||||
continue
|
continue
|
||||||
|
else:
|
||||||
|
break
|
||||||
video = e.get('video')
|
video = e.get('video')
|
||||||
if isinstance(video, dict) and video.get('@type') == 'VideoObject':
|
if isinstance(video, dict) and video.get('@type') == 'VideoObject':
|
||||||
extract_video_object(video)
|
extract_video_object(video)
|
||||||
|
if expected_type is None:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
break
|
break
|
||||||
return dict((k, v) for k, v in info.items() if v is not None)
|
return dict((k, v) for k, v in info.items() if v is not None)
|
||||||
|
|
||||||
@ -2820,7 +2843,7 @@ class InfoExtractor(object):
|
|||||||
|
|
||||||
def _set_cookie(self, domain, name, value, expire_time=None, port=None,
|
def _set_cookie(self, domain, name, value, expire_time=None, port=None,
|
||||||
path='/', secure=False, discard=False, rest={}, **kwargs):
|
path='/', secure=False, discard=False, rest={}, **kwargs):
|
||||||
cookie = compat_cookiejar.Cookie(
|
cookie = compat_cookiejar_Cookie(
|
||||||
0, name, value, port, port is not None, domain, True,
|
0, name, value, port, port is not None, domain, True,
|
||||||
domain.startswith('.'), path, True, secure, expire_time,
|
domain.startswith('.'), path, True, secure, expire_time,
|
||||||
discard, None, None, rest)
|
discard, None, None, rest)
|
||||||
|
@ -13,6 +13,7 @@ from ..compat import (
|
|||||||
compat_b64decode,
|
compat_b64decode,
|
||||||
compat_etree_Element,
|
compat_etree_Element,
|
||||||
compat_etree_fromstring,
|
compat_etree_fromstring,
|
||||||
|
compat_str,
|
||||||
compat_urllib_parse_urlencode,
|
compat_urllib_parse_urlencode,
|
||||||
compat_urllib_request,
|
compat_urllib_request,
|
||||||
compat_urlparse,
|
compat_urlparse,
|
||||||
@ -25,9 +26,9 @@ from ..utils import (
|
|||||||
intlist_to_bytes,
|
intlist_to_bytes,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
lowercase_escape,
|
lowercase_escape,
|
||||||
|
merge_dicts,
|
||||||
remove_end,
|
remove_end,
|
||||||
sanitized_Request,
|
sanitized_Request,
|
||||||
unified_strdate,
|
|
||||||
urlencode_postdata,
|
urlencode_postdata,
|
||||||
xpath_text,
|
xpath_text,
|
||||||
)
|
)
|
||||||
@ -136,6 +137,7 @@ class CrunchyrollIE(CrunchyrollBaseIE, VRVIE):
|
|||||||
# rtmp
|
# rtmp
|
||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
},
|
},
|
||||||
|
'skip': 'Video gone',
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://www.crunchyroll.com/media-589804/culture-japan-1',
|
'url': 'http://www.crunchyroll.com/media-589804/culture-japan-1',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
@ -157,11 +159,12 @@ class CrunchyrollIE(CrunchyrollBaseIE, VRVIE):
|
|||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '702409',
|
'id': '702409',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Re:ZERO -Starting Life in Another World- Episode 5 – The Morning of Our Promise Is Still Distant',
|
'title': compat_str,
|
||||||
'description': 'md5:97664de1ab24bbf77a9c01918cb7dca9',
|
'description': compat_str,
|
||||||
'thumbnail': r're:^https?://.*\.jpg$',
|
'thumbnail': r're:^https?://.*\.jpg$',
|
||||||
'uploader': 'TV TOKYO',
|
'uploader': 'Re:Zero Partners',
|
||||||
'upload_date': '20160508',
|
'timestamp': 1462098900,
|
||||||
|
'upload_date': '20160501',
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
# m3u8 download
|
# m3u8 download
|
||||||
@ -172,12 +175,13 @@ class CrunchyrollIE(CrunchyrollBaseIE, VRVIE):
|
|||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '727589',
|
'id': '727589',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': "KONOSUBA -God's blessing on this wonderful world! 2 Episode 1 – Give Me Deliverance From This Judicial Injustice!",
|
'title': compat_str,
|
||||||
'description': 'md5:cbcf05e528124b0f3a0a419fc805ea7d',
|
'description': compat_str,
|
||||||
'thumbnail': r're:^https?://.*\.jpg$',
|
'thumbnail': r're:^https?://.*\.jpg$',
|
||||||
'uploader': 'Kadokawa Pictures Inc.',
|
'uploader': 'Kadokawa Pictures Inc.',
|
||||||
'upload_date': '20170118',
|
'timestamp': 1484130900,
|
||||||
'series': "KONOSUBA -God's blessing on this wonderful world!",
|
'upload_date': '20170111',
|
||||||
|
'series': compat_str,
|
||||||
'season': "KONOSUBA -God's blessing on this wonderful world! 2",
|
'season': "KONOSUBA -God's blessing on this wonderful world! 2",
|
||||||
'season_number': 2,
|
'season_number': 2,
|
||||||
'episode': 'Give Me Deliverance From This Judicial Injustice!',
|
'episode': 'Give Me Deliverance From This Judicial Injustice!',
|
||||||
@ -200,10 +204,11 @@ class CrunchyrollIE(CrunchyrollBaseIE, VRVIE):
|
|||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '535080',
|
'id': '535080',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': '11eyes Episode 1 – Red Night ~ Piros éjszaka',
|
'title': compat_str,
|
||||||
'description': 'Kakeru and Yuka are thrown into an alternate nightmarish world they call "Red Night".',
|
'description': compat_str,
|
||||||
'uploader': 'Marvelous AQL Inc.',
|
'uploader': 'Marvelous AQL Inc.',
|
||||||
'upload_date': '20091021',
|
'timestamp': 1255512600,
|
||||||
|
'upload_date': '20091014',
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
# Just test metadata extraction
|
# Just test metadata extraction
|
||||||
@ -224,15 +229,17 @@ class CrunchyrollIE(CrunchyrollBaseIE, VRVIE):
|
|||||||
# just test metadata extraction
|
# just test metadata extraction
|
||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
},
|
},
|
||||||
|
'skip': 'Video gone',
|
||||||
}, {
|
}, {
|
||||||
# A video with a vastly different season name compared to the series name
|
# A video with a vastly different season name compared to the series name
|
||||||
'url': 'http://www.crunchyroll.com/nyarko-san-another-crawling-chaos/episode-1-test-590532',
|
'url': 'http://www.crunchyroll.com/nyarko-san-another-crawling-chaos/episode-1-test-590532',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '590532',
|
'id': '590532',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Haiyoru! Nyaruani (ONA) Episode 1 – Test',
|
'title': compat_str,
|
||||||
'description': 'Mahiro and Nyaruko talk about official certification.',
|
'description': compat_str,
|
||||||
'uploader': 'TV TOKYO',
|
'uploader': 'TV TOKYO',
|
||||||
|
'timestamp': 1330956000,
|
||||||
'upload_date': '20120305',
|
'upload_date': '20120305',
|
||||||
'series': 'Nyarko-san: Another Crawling Chaos',
|
'series': 'Nyarko-san: Another Crawling Chaos',
|
||||||
'season': 'Haiyoru! Nyaruani (ONA)',
|
'season': 'Haiyoru! Nyaruani (ONA)',
|
||||||
@ -442,23 +449,21 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
|
|||||||
webpage, 'language', default=None, group='lang')
|
webpage, 'language', default=None, group='lang')
|
||||||
|
|
||||||
video_title = self._html_search_regex(
|
video_title = self._html_search_regex(
|
||||||
r'(?s)<h1[^>]*>((?:(?!<h1).)*?<span[^>]+itemprop=["\']title["\'][^>]*>(?:(?!<h1).)+?)</h1>',
|
(r'(?s)<h1[^>]*>((?:(?!<h1).)*?<(?:span[^>]+itemprop=["\']title["\']|meta[^>]+itemprop=["\']position["\'])[^>]*>(?:(?!<h1).)+?)</h1>',
|
||||||
webpage, 'video_title')
|
r'<title>(.+?),\s+-\s+.+? Crunchyroll'),
|
||||||
|
webpage, 'video_title', default=None)
|
||||||
|
if not video_title:
|
||||||
|
video_title = re.sub(r'^Watch\s+', '', self._og_search_description(webpage))
|
||||||
video_title = re.sub(r' {2,}', ' ', video_title)
|
video_title = re.sub(r' {2,}', ' ', video_title)
|
||||||
video_description = (self._parse_json(self._html_search_regex(
|
video_description = (self._parse_json(self._html_search_regex(
|
||||||
r'<script[^>]*>\s*.+?\[media_id=%s\].+?({.+?"description"\s*:.+?})\);' % video_id,
|
r'<script[^>]*>\s*.+?\[media_id=%s\].+?({.+?"description"\s*:.+?})\);' % video_id,
|
||||||
webpage, 'description', default='{}'), video_id) or media_metadata).get('description')
|
webpage, 'description', default='{}'), video_id) or media_metadata).get('description')
|
||||||
if video_description:
|
if video_description:
|
||||||
video_description = lowercase_escape(video_description.replace(r'\r\n', '\n'))
|
video_description = lowercase_escape(video_description.replace(r'\r\n', '\n'))
|
||||||
video_upload_date = self._html_search_regex(
|
|
||||||
[r'<div>Availability for free users:(.+?)</div>', r'<div>[^<>]+<span>\s*(.+?\d{4})\s*</span></div>'],
|
|
||||||
webpage, 'video_upload_date', fatal=False, flags=re.DOTALL)
|
|
||||||
if video_upload_date:
|
|
||||||
video_upload_date = unified_strdate(video_upload_date)
|
|
||||||
video_uploader = self._html_search_regex(
|
video_uploader = self._html_search_regex(
|
||||||
# try looking for both an uploader that's a link and one that's not
|
# try looking for both an uploader that's a link and one that's not
|
||||||
[r'<a[^>]+href="/publisher/[^"]+"[^>]*>([^<]+)</a>', r'<div>\s*Publisher:\s*<span>\s*(.+?)\s*</span>\s*</div>'],
|
[r'<a[^>]+href="/publisher/[^"]+"[^>]*>([^<]+)</a>', r'<div>\s*Publisher:\s*<span>\s*(.+?)\s*</span>\s*</div>'],
|
||||||
webpage, 'video_uploader', fatal=False)
|
webpage, 'video_uploader', default=False)
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for stream in media.get('streams', []):
|
for stream in media.get('streams', []):
|
||||||
@ -611,14 +616,15 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
|
|||||||
r'(?s)<h\d[^>]+id=["\']showmedia_about_episode_num[^>]+>.+?</h\d>\s*<h4>\s*Season (\d+)',
|
r'(?s)<h\d[^>]+id=["\']showmedia_about_episode_num[^>]+>.+?</h\d>\s*<h4>\s*Season (\d+)',
|
||||||
webpage, 'season number', default=None))
|
webpage, 'season number', default=None))
|
||||||
|
|
||||||
return {
|
info = self._search_json_ld(webpage, video_id, default={})
|
||||||
|
|
||||||
|
return merge_dicts({
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': video_title,
|
'title': video_title,
|
||||||
'description': video_description,
|
'description': video_description,
|
||||||
'duration': duration,
|
'duration': duration,
|
||||||
'thumbnail': thumbnail,
|
'thumbnail': thumbnail,
|
||||||
'uploader': video_uploader,
|
'uploader': video_uploader,
|
||||||
'upload_date': video_upload_date,
|
|
||||||
'series': series,
|
'series': series,
|
||||||
'season': season,
|
'season': season,
|
||||||
'season_number': season_number,
|
'season_number': season_number,
|
||||||
@ -626,7 +632,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
|
|||||||
'episode_number': episode_number,
|
'episode_number': episode_number,
|
||||||
'subtitles': subtitles,
|
'subtitles': subtitles,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
}
|
}, info)
|
||||||
|
|
||||||
|
|
||||||
class CrunchyrollShowPlaylistIE(CrunchyrollBaseIE):
|
class CrunchyrollShowPlaylistIE(CrunchyrollBaseIE):
|
||||||
|
@ -32,7 +32,7 @@ class DailymotionBaseInfoExtractor(InfoExtractor):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_cookie_value(cookies, name):
|
def _get_cookie_value(cookies, name):
|
||||||
cookie = cookies.get('name')
|
cookie = cookies.get(name)
|
||||||
if cookie:
|
if cookie:
|
||||||
return cookie.value
|
return cookie.value
|
||||||
|
|
||||||
|
@ -804,6 +804,16 @@ from .orf import (
|
|||||||
ORFFM4IE,
|
ORFFM4IE,
|
||||||
ORFFM4StoryIE,
|
ORFFM4StoryIE,
|
||||||
ORFOE1IE,
|
ORFOE1IE,
|
||||||
|
ORFOE3IE,
|
||||||
|
ORFNOEIE,
|
||||||
|
ORFWIEIE,
|
||||||
|
ORFBGLIE,
|
||||||
|
ORFOOEIE,
|
||||||
|
ORFSTMIE,
|
||||||
|
ORFKTNIE,
|
||||||
|
ORFSBGIE,
|
||||||
|
ORFTIRIE,
|
||||||
|
ORFVBGIE,
|
||||||
ORFIPTVIE,
|
ORFIPTVIE,
|
||||||
)
|
)
|
||||||
from .outsidetv import OutsideTVIE
|
from .outsidetv import OutsideTVIE
|
||||||
|
@ -162,13 +162,12 @@ class ORFTVthekIE(InfoExtractor):
|
|||||||
class ORFRadioIE(InfoExtractor):
|
class ORFRadioIE(InfoExtractor):
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
station = mobj.group('station')
|
|
||||||
show_date = mobj.group('date')
|
show_date = mobj.group('date')
|
||||||
show_id = mobj.group('show')
|
show_id = mobj.group('show')
|
||||||
|
|
||||||
data = self._download_json(
|
data = self._download_json(
|
||||||
'http://audioapi.orf.at/%s/api/json/current/broadcast/%s/%s'
|
'http://audioapi.orf.at/%s/api/json/current/broadcast/%s/%s'
|
||||||
% (station, show_id, show_date), show_id)
|
% (self._API_STATION, show_id, show_date), show_id)
|
||||||
|
|
||||||
entries = []
|
entries = []
|
||||||
for info in data['streams']:
|
for info in data['streams']:
|
||||||
@ -183,7 +182,7 @@ class ORFRadioIE(InfoExtractor):
|
|||||||
duration = end - start if end and start else None
|
duration = end - start if end and start else None
|
||||||
entries.append({
|
entries.append({
|
||||||
'id': loop_stream_id.replace('.mp3', ''),
|
'id': loop_stream_id.replace('.mp3', ''),
|
||||||
'url': 'http://loopstream01.apa.at/?channel=%s&id=%s' % (station, loop_stream_id),
|
'url': 'http://loopstream01.apa.at/?channel=%s&id=%s' % (self._LOOP_STATION, loop_stream_id),
|
||||||
'title': title,
|
'title': title,
|
||||||
'description': clean_html(data.get('subtitle')),
|
'description': clean_html(data.get('subtitle')),
|
||||||
'duration': duration,
|
'duration': duration,
|
||||||
@ -205,6 +204,8 @@ class ORFFM4IE(ORFRadioIE):
|
|||||||
IE_NAME = 'orf:fm4'
|
IE_NAME = 'orf:fm4'
|
||||||
IE_DESC = 'radio FM4'
|
IE_DESC = 'radio FM4'
|
||||||
_VALID_URL = r'https?://(?P<station>fm4)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>4\w+)'
|
_VALID_URL = r'https?://(?P<station>fm4)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>4\w+)'
|
||||||
|
_API_STATION = 'fm4'
|
||||||
|
_LOOP_STATION = 'fm4'
|
||||||
|
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'http://fm4.orf.at/player/20170107/4CC',
|
'url': 'http://fm4.orf.at/player/20170107/4CC',
|
||||||
@ -223,10 +224,142 @@ class ORFFM4IE(ORFRadioIE):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ORFNOEIE(ORFRadioIE):
|
||||||
|
IE_NAME = 'orf:noe'
|
||||||
|
IE_DESC = 'Radio Niederösterreich'
|
||||||
|
_VALID_URL = r'https?://(?P<station>noe)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
|
||||||
|
_API_STATION = 'noe'
|
||||||
|
_LOOP_STATION = 'oe2n'
|
||||||
|
|
||||||
|
_TEST = {
|
||||||
|
'url': 'https://noe.orf.at/player/20200423/NGM',
|
||||||
|
'only_matching': True,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ORFWIEIE(ORFRadioIE):
|
||||||
|
IE_NAME = 'orf:wien'
|
||||||
|
IE_DESC = 'Radio Wien'
|
||||||
|
_VALID_URL = r'https?://(?P<station>wien)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
|
||||||
|
_API_STATION = 'wie'
|
||||||
|
_LOOP_STATION = 'oe2w'
|
||||||
|
|
||||||
|
_TEST = {
|
||||||
|
'url': 'https://wien.orf.at/player/20200423/WGUM',
|
||||||
|
'only_matching': True,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ORFBGLIE(ORFRadioIE):
|
||||||
|
IE_NAME = 'orf:burgenland'
|
||||||
|
IE_DESC = 'Radio Burgenland'
|
||||||
|
_VALID_URL = r'https?://(?P<station>burgenland)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
|
||||||
|
_API_STATION = 'bgl'
|
||||||
|
_LOOP_STATION = 'oe2b'
|
||||||
|
|
||||||
|
_TEST = {
|
||||||
|
'url': 'https://burgenland.orf.at/player/20200423/BGM',
|
||||||
|
'only_matching': True,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ORFOOEIE(ORFRadioIE):
|
||||||
|
IE_NAME = 'orf:oberoesterreich'
|
||||||
|
IE_DESC = 'Radio Oberösterreich'
|
||||||
|
_VALID_URL = r'https?://(?P<station>ooe)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
|
||||||
|
_API_STATION = 'ooe'
|
||||||
|
_LOOP_STATION = 'oe2o'
|
||||||
|
|
||||||
|
_TEST = {
|
||||||
|
'url': 'https://ooe.orf.at/player/20200423/OGMO',
|
||||||
|
'only_matching': True,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ORFSTMIE(ORFRadioIE):
|
||||||
|
IE_NAME = 'orf:steiermark'
|
||||||
|
IE_DESC = 'Radio Steiermark'
|
||||||
|
_VALID_URL = r'https?://(?P<station>steiermark)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
|
||||||
|
_API_STATION = 'stm'
|
||||||
|
_LOOP_STATION = 'oe2st'
|
||||||
|
|
||||||
|
_TEST = {
|
||||||
|
'url': 'https://steiermark.orf.at/player/20200423/STGMS',
|
||||||
|
'only_matching': True,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ORFKTNIE(ORFRadioIE):
|
||||||
|
IE_NAME = 'orf:kaernten'
|
||||||
|
IE_DESC = 'Radio Kärnten'
|
||||||
|
_VALID_URL = r'https?://(?P<station>kaernten)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
|
||||||
|
_API_STATION = 'ktn'
|
||||||
|
_LOOP_STATION = 'oe2k'
|
||||||
|
|
||||||
|
_TEST = {
|
||||||
|
'url': 'https://kaernten.orf.at/player/20200423/KGUMO',
|
||||||
|
'only_matching': True,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ORFSBGIE(ORFRadioIE):
|
||||||
|
IE_NAME = 'orf:salzburg'
|
||||||
|
IE_DESC = 'Radio Salzburg'
|
||||||
|
_VALID_URL = r'https?://(?P<station>salzburg)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
|
||||||
|
_API_STATION = 'sbg'
|
||||||
|
_LOOP_STATION = 'oe2s'
|
||||||
|
|
||||||
|
_TEST = {
|
||||||
|
'url': 'https://salzburg.orf.at/player/20200423/SGUM',
|
||||||
|
'only_matching': True,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ORFTIRIE(ORFRadioIE):
|
||||||
|
IE_NAME = 'orf:tirol'
|
||||||
|
IE_DESC = 'Radio Tirol'
|
||||||
|
_VALID_URL = r'https?://(?P<station>tirol)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
|
||||||
|
_API_STATION = 'tir'
|
||||||
|
_LOOP_STATION = 'oe2t'
|
||||||
|
|
||||||
|
_TEST = {
|
||||||
|
'url': 'https://tirol.orf.at/player/20200423/TGUMO',
|
||||||
|
'only_matching': True,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ORFVBGIE(ORFRadioIE):
|
||||||
|
IE_NAME = 'orf:vorarlberg'
|
||||||
|
IE_DESC = 'Radio Vorarlberg'
|
||||||
|
_VALID_URL = r'https?://(?P<station>vorarlberg)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
|
||||||
|
_API_STATION = 'vbg'
|
||||||
|
_LOOP_STATION = 'oe2v'
|
||||||
|
|
||||||
|
_TEST = {
|
||||||
|
'url': 'https://vorarlberg.orf.at/player/20200423/VGUM',
|
||||||
|
'only_matching': True,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ORFOE3IE(ORFRadioIE):
|
||||||
|
IE_NAME = 'orf:oe3'
|
||||||
|
IE_DESC = 'Radio Österreich 3'
|
||||||
|
_VALID_URL = r'https?://(?P<station>oe3)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
|
||||||
|
_API_STATION = 'oe3'
|
||||||
|
_LOOP_STATION = 'oe3'
|
||||||
|
|
||||||
|
_TEST = {
|
||||||
|
'url': 'https://oe3.orf.at/player/20200424/3WEK',
|
||||||
|
'only_matching': True,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class ORFOE1IE(ORFRadioIE):
|
class ORFOE1IE(ORFRadioIE):
|
||||||
IE_NAME = 'orf:oe1'
|
IE_NAME = 'orf:oe1'
|
||||||
IE_DESC = 'Radio Österreich 1'
|
IE_DESC = 'Radio Österreich 1'
|
||||||
_VALID_URL = r'https?://(?P<station>oe1)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
|
_VALID_URL = r'https?://(?P<station>oe1)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
|
||||||
|
_API_STATION = 'oe1'
|
||||||
|
_LOOP_STATION = 'oe1'
|
||||||
|
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'http://oe1.orf.at/player/20170108/456544',
|
'url': 'http://oe1.orf.at/player/20170108/456544',
|
||||||
|
@ -82,17 +82,6 @@ class PuhuTVIE(InfoExtractor):
|
|||||||
urls = []
|
urls = []
|
||||||
formats = []
|
formats = []
|
||||||
|
|
||||||
def add_http_from_hls(m3u8_f):
|
|
||||||
http_url = m3u8_f['url'].replace('/hls/', '/mp4/').replace('/chunklist.m3u8', '.mp4')
|
|
||||||
if http_url != m3u8_f['url']:
|
|
||||||
f = m3u8_f.copy()
|
|
||||||
f.update({
|
|
||||||
'format_id': f['format_id'].replace('hls', 'http'),
|
|
||||||
'protocol': 'http',
|
|
||||||
'url': http_url,
|
|
||||||
})
|
|
||||||
formats.append(f)
|
|
||||||
|
|
||||||
for video in videos['data']['videos']:
|
for video in videos['data']['videos']:
|
||||||
media_url = url_or_none(video.get('url'))
|
media_url = url_or_none(video.get('url'))
|
||||||
if not media_url or media_url in urls:
|
if not media_url or media_url in urls:
|
||||||
@ -101,12 +90,9 @@ class PuhuTVIE(InfoExtractor):
|
|||||||
|
|
||||||
playlist = video.get('is_playlist')
|
playlist = video.get('is_playlist')
|
||||||
if (video.get('stream_type') == 'hls' and playlist is True) or 'playlist.m3u8' in media_url:
|
if (video.get('stream_type') == 'hls' and playlist is True) or 'playlist.m3u8' in media_url:
|
||||||
m3u8_formats = self._extract_m3u8_formats(
|
formats.extend(self._extract_m3u8_formats(
|
||||||
media_url, video_id, 'mp4', entry_protocol='m3u8_native',
|
media_url, video_id, 'mp4', entry_protocol='m3u8_native',
|
||||||
m3u8_id='hls', fatal=False)
|
m3u8_id='hls', fatal=False))
|
||||||
for m3u8_f in m3u8_formats:
|
|
||||||
formats.append(m3u8_f)
|
|
||||||
add_http_from_hls(m3u8_f)
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
quality = int_or_none(video.get('quality'))
|
quality = int_or_none(video.get('quality'))
|
||||||
@ -128,8 +114,6 @@ class PuhuTVIE(InfoExtractor):
|
|||||||
format_id += '-%sp' % quality
|
format_id += '-%sp' % quality
|
||||||
f['format_id'] = format_id
|
f['format_id'] = format_id
|
||||||
formats.append(f)
|
formats.append(f)
|
||||||
if is_hls:
|
|
||||||
add_http_from_hls(f)
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
creator = try_get(
|
creator = try_get(
|
||||||
|
@ -6,7 +6,6 @@ import re
|
|||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import (
|
from ..compat import (
|
||||||
compat_HTTPError,
|
compat_HTTPError,
|
||||||
compat_str,
|
|
||||||
compat_urlparse,
|
compat_urlparse,
|
||||||
)
|
)
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
@ -15,9 +14,7 @@ from ..utils import (
|
|||||||
int_or_none,
|
int_or_none,
|
||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
qualities,
|
qualities,
|
||||||
smuggle_url,
|
|
||||||
try_get,
|
try_get,
|
||||||
unsmuggle_url,
|
|
||||||
update_url_query,
|
update_url_query,
|
||||||
url_or_none,
|
url_or_none,
|
||||||
)
|
)
|
||||||
@ -235,11 +232,6 @@ class TVPlayIE(InfoExtractor):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
url, smuggled_data = unsmuggle_url(url, {})
|
|
||||||
self._initialize_geo_bypass({
|
|
||||||
'countries': smuggled_data.get('geo_countries'),
|
|
||||||
})
|
|
||||||
|
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
geo_country = self._search_regex(
|
geo_country = self._search_regex(
|
||||||
r'https?://[^/]+\.([a-z]{2})', url,
|
r'https?://[^/]+\.([a-z]{2})', url,
|
||||||
@ -285,8 +277,6 @@ class TVPlayIE(InfoExtractor):
|
|||||||
'ext': ext,
|
'ext': ext,
|
||||||
}
|
}
|
||||||
if video_url.startswith('rtmp'):
|
if video_url.startswith('rtmp'):
|
||||||
if smuggled_data.get('skip_rtmp'):
|
|
||||||
continue
|
|
||||||
m = re.search(
|
m = re.search(
|
||||||
r'^(?P<url>rtmp://[^/]+/(?P<app>[^/]+))/(?P<playpath>.+)$', video_url)
|
r'^(?P<url>rtmp://[^/]+/(?P<app>[^/]+))/(?P<playpath>.+)$', video_url)
|
||||||
if not m:
|
if not m:
|
||||||
@ -347,115 +337,80 @@ class ViafreeIE(InfoExtractor):
|
|||||||
_VALID_URL = r'''(?x)
|
_VALID_URL = r'''(?x)
|
||||||
https?://
|
https?://
|
||||||
(?:www\.)?
|
(?:www\.)?
|
||||||
viafree\.
|
viafree\.(?P<country>dk|no|se)
|
||||||
(?:
|
/(?P<id>program(?:mer)?/(?:[^/]+/)+[^/?#&]+)
|
||||||
(?:dk|no)/programmer|
|
|
||||||
se/program
|
|
||||||
)
|
|
||||||
/(?:[^/]+/)+(?P<id>[^/?#&]+)
|
|
||||||
'''
|
'''
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'http://www.viafree.se/program/livsstil/husraddarna/sasong-2/avsnitt-2',
|
'url': 'http://www.viafree.no/programmer/underholdning/det-beste-vorspielet/sesong-2/episode-1',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '395375',
|
'id': '757786',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Husräddarna S02E02',
|
'title': 'Det beste vorspielet - Sesong 2 - Episode 1',
|
||||||
'description': 'md5:4db5c933e37db629b5a2f75dfb34829e',
|
'description': 'md5:b632cb848331404ccacd8cd03e83b4c3',
|
||||||
'series': 'Husräddarna',
|
'series': 'Det beste vorspielet',
|
||||||
'season': 'Säsong 2',
|
|
||||||
'season_number': 2,
|
'season_number': 2,
|
||||||
'duration': 2576,
|
'duration': 1116,
|
||||||
'timestamp': 1400596321,
|
'timestamp': 1471200600,
|
||||||
'upload_date': '20140520',
|
'upload_date': '20160814',
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
},
|
},
|
||||||
'add_ie': [TVPlayIE.ie_key()],
|
|
||||||
}, {
|
}, {
|
||||||
# with relatedClips
|
# with relatedClips
|
||||||
'url': 'http://www.viafree.se/program/reality/sommaren-med-youtube-stjarnorna/sasong-1/avsnitt-1',
|
'url': 'http://www.viafree.se/program/reality/sommaren-med-youtube-stjarnorna/sasong-1/avsnitt-1',
|
||||||
'info_dict': {
|
'only_matching': True,
|
||||||
'id': '758770',
|
|
||||||
'ext': 'mp4',
|
|
||||||
'title': 'Sommaren med YouTube-stjärnorna S01E01',
|
|
||||||
'description': 'md5:2bc69dce2c4bb48391e858539bbb0e3f',
|
|
||||||
'series': 'Sommaren med YouTube-stjärnorna',
|
|
||||||
'season': 'Säsong 1',
|
|
||||||
'season_number': 1,
|
|
||||||
'duration': 1326,
|
|
||||||
'timestamp': 1470905572,
|
|
||||||
'upload_date': '20160811',
|
|
||||||
},
|
|
||||||
'params': {
|
|
||||||
'skip_download': True,
|
|
||||||
},
|
|
||||||
'add_ie': [TVPlayIE.ie_key()],
|
|
||||||
}, {
|
}, {
|
||||||
# Different og:image URL schema
|
# Different og:image URL schema
|
||||||
'url': 'http://www.viafree.se/program/reality/sommaren-med-youtube-stjarnorna/sasong-1/avsnitt-2',
|
'url': 'http://www.viafree.se/program/reality/sommaren-med-youtube-stjarnorna/sasong-1/avsnitt-2',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://www.viafree.no/programmer/underholdning/det-beste-vorspielet/sesong-2/episode-1',
|
'url': 'http://www.viafree.se/program/livsstil/husraddarna/sasong-2/avsnitt-2',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://www.viafree.dk/programmer/reality/paradise-hotel/saeson-7/episode-5',
|
'url': 'http://www.viafree.dk/programmer/reality/paradise-hotel/saeson-7/episode-5',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
_GEO_BYPASS = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def suitable(cls, url):
|
def suitable(cls, url):
|
||||||
return False if TVPlayIE.suitable(url) else super(ViafreeIE, cls).suitable(url)
|
return False if TVPlayIE.suitable(url) else super(ViafreeIE, cls).suitable(url)
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
country, path = re.match(self._VALID_URL, url).groups()
|
||||||
|
content = self._download_json(
|
||||||
|
'https://viafree-content.mtg-api.com/viafree-content/v1/%s/path/%s' % (country, path), path)
|
||||||
|
program = content['_embedded']['viafreeBlocks'][0]['_embedded']['program']
|
||||||
|
guid = program['guid']
|
||||||
|
meta = content['meta']
|
||||||
|
title = meta['title']
|
||||||
|
|
||||||
webpage = self._download_webpage(url, video_id)
|
try:
|
||||||
|
stream_href = self._download_json(
|
||||||
|
program['_links']['streamLink']['href'], guid,
|
||||||
|
headers=self.geo_verification_headers())['embedded']['prioritizedStreams'][0]['links']['stream']['href']
|
||||||
|
except ExtractorError as e:
|
||||||
|
if isinstance(e.cause, compat_HTTPError) and e.cause.code == 403:
|
||||||
|
self.raise_geo_restricted(countries=[country])
|
||||||
|
raise
|
||||||
|
|
||||||
data = self._parse_json(
|
formats = self._extract_m3u8_formats(stream_href, guid, 'mp4')
|
||||||
self._search_regex(
|
self._sort_formats(formats)
|
||||||
r'(?s)window\.App\s*=\s*({.+?})\s*;\s*</script',
|
episode = program.get('episode') or {}
|
||||||
webpage, 'data', default='{}'),
|
|
||||||
video_id, transform_source=lambda x: re.sub(
|
|
||||||
r'(?s)function\s+[a-zA-Z_][\da-zA-Z_]*\s*\([^)]*\)\s*{[^}]*}\s*',
|
|
||||||
'null', x), fatal=False)
|
|
||||||
|
|
||||||
video_id = None
|
return {
|
||||||
|
'id': guid,
|
||||||
if data:
|
'title': title,
|
||||||
video_id = try_get(
|
'thumbnail': meta.get('image'),
|
||||||
data, lambda x: x['context']['dispatcher']['stores'][
|
'description': meta.get('description'),
|
||||||
'ContentPageProgramStore']['currentVideo']['id'],
|
'series': episode.get('seriesTitle'),
|
||||||
compat_str)
|
'episode_number': int_or_none(episode.get('episodeNumber')),
|
||||||
|
'season_number': int_or_none(episode.get('seasonNumber')),
|
||||||
# Fallback #1 (extract from og:image URL schema)
|
'duration': int_or_none(try_get(program, lambda x: x['video']['duration']['milliseconds']), 1000),
|
||||||
if not video_id:
|
'timestamp': parse_iso8601(try_get(program, lambda x: x['availability']['start'])),
|
||||||
thumbnail = self._og_search_thumbnail(webpage, default=None)
|
'formats': formats,
|
||||||
if thumbnail:
|
}
|
||||||
video_id = self._search_regex(
|
|
||||||
# Patterns seen:
|
|
||||||
# http://cdn.playapi.mtgx.tv/imagecache/600x315/cloud/content-images/inbox/765166/a2e95e5f1d735bab9f309fa345cc3f25.jpg
|
|
||||||
# http://cdn.playapi.mtgx.tv/imagecache/600x315/cloud/content-images/seasons/15204/758770/4a5ba509ca8bc043e1ebd1a76131cdf2.jpg
|
|
||||||
r'https?://[^/]+/imagecache/(?:[^/]+/)+(\d{6,})/',
|
|
||||||
thumbnail, 'video id', default=None)
|
|
||||||
|
|
||||||
# Fallback #2. Extract from raw JSON string.
|
|
||||||
# May extract wrong video id if relatedClips is present.
|
|
||||||
if not video_id:
|
|
||||||
video_id = self._search_regex(
|
|
||||||
r'currentVideo["\']\s*:\s*.+?["\']id["\']\s*:\s*["\'](\d{6,})',
|
|
||||||
webpage, 'video id')
|
|
||||||
|
|
||||||
return self.url_result(
|
|
||||||
smuggle_url(
|
|
||||||
'mtg:%s' % video_id,
|
|
||||||
{
|
|
||||||
'geo_countries': [
|
|
||||||
compat_urlparse.urlparse(url).netloc.rsplit('.', 1)[-1]],
|
|
||||||
# rtmp host mtgfs.fplive.net for viafree is unresolvable
|
|
||||||
'skip_rtmp': True,
|
|
||||||
}),
|
|
||||||
ie=TVPlayIE.ie_key(), video_id=video_id)
|
|
||||||
|
|
||||||
|
|
||||||
class TVPlayHomeIE(InfoExtractor):
|
class TVPlayHomeIE(InfoExtractor):
|
||||||
|
@ -2,12 +2,17 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..compat import (
|
||||||
|
compat_str,
|
||||||
|
compat_urllib_parse_urlencode,
|
||||||
|
)
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
clean_html,
|
clean_html,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
parse_duration,
|
parse_duration,
|
||||||
|
parse_iso8601,
|
||||||
|
qualities,
|
||||||
update_url_query,
|
update_url_query,
|
||||||
str_or_none,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -16,21 +21,25 @@ class UOLIE(InfoExtractor):
|
|||||||
_VALID_URL = r'https?://(?:.+?\.)?uol\.com\.br/.*?(?:(?:mediaId|v)=|view/(?:[a-z0-9]+/)?|video(?:=|/(?:\d{4}/\d{2}/\d{2}/)?))(?P<id>\d+|[\w-]+-[A-Z0-9]+)'
|
_VALID_URL = r'https?://(?:.+?\.)?uol\.com\.br/.*?(?:(?:mediaId|v)=|view/(?:[a-z0-9]+/)?|video(?:=|/(?:\d{4}/\d{2}/\d{2}/)?))(?P<id>\d+|[\w-]+-[A-Z0-9]+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'http://player.mais.uol.com.br/player_video_v3.swf?mediaId=15951931',
|
'url': 'http://player.mais.uol.com.br/player_video_v3.swf?mediaId=15951931',
|
||||||
'md5': '25291da27dc45e0afb5718a8603d3816',
|
'md5': '4f1e26683979715ff64e4e29099cf020',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '15951931',
|
'id': '15951931',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Miss simpatia é encontrada morta',
|
'title': 'Miss simpatia é encontrada morta',
|
||||||
'description': 'md5:3f8c11a0c0556d66daf7e5b45ef823b2',
|
'description': 'md5:3f8c11a0c0556d66daf7e5b45ef823b2',
|
||||||
|
'timestamp': 1470421860,
|
||||||
|
'upload_date': '20160805',
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://tvuol.uol.com.br/video/incendio-destroi-uma-das-maiores-casas-noturnas-de-londres-04024E9A3268D4C95326',
|
'url': 'http://tvuol.uol.com.br/video/incendio-destroi-uma-das-maiores-casas-noturnas-de-londres-04024E9A3268D4C95326',
|
||||||
'md5': 'e41a2fb7b7398a3a46b6af37b15c00c9',
|
'md5': '2850a0e8dfa0a7307e04a96c5bdc5bc2',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '15954259',
|
'id': '15954259',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Incêndio destrói uma das maiores casas noturnas de Londres',
|
'title': 'Incêndio destrói uma das maiores casas noturnas de Londres',
|
||||||
'description': 'Em Londres, um incêndio destruiu uma das maiores boates da cidade. Não há informações sobre vítimas.',
|
'description': 'Em Londres, um incêndio destruiu uma das maiores boates da cidade. Não há informações sobre vítimas.',
|
||||||
|
'timestamp': 1470674520,
|
||||||
|
'upload_date': '20160808',
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://mais.uol.com.br/static/uolplayer/index.html?mediaId=15951931',
|
'url': 'http://mais.uol.com.br/static/uolplayer/index.html?mediaId=15951931',
|
||||||
@ -55,91 +64,55 @@ class UOLIE(InfoExtractor):
|
|||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
_FORMATS = {
|
|
||||||
'2': {
|
|
||||||
'width': 640,
|
|
||||||
'height': 360,
|
|
||||||
},
|
|
||||||
'5': {
|
|
||||||
'width': 1280,
|
|
||||||
'height': 720,
|
|
||||||
},
|
|
||||||
'6': {
|
|
||||||
'width': 426,
|
|
||||||
'height': 240,
|
|
||||||
},
|
|
||||||
'7': {
|
|
||||||
'width': 1920,
|
|
||||||
'height': 1080,
|
|
||||||
},
|
|
||||||
'8': {
|
|
||||||
'width': 192,
|
|
||||||
'height': 144,
|
|
||||||
},
|
|
||||||
'9': {
|
|
||||||
'width': 568,
|
|
||||||
'height': 320,
|
|
||||||
},
|
|
||||||
'11': {
|
|
||||||
'width': 640,
|
|
||||||
'height': 360,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
media_id = None
|
|
||||||
|
|
||||||
if video_id.isdigit():
|
|
||||||
media_id = video_id
|
|
||||||
|
|
||||||
if not media_id:
|
|
||||||
embed_page = self._download_webpage(
|
|
||||||
'https://jsuol.com.br/c/tv/uol/embed/?params=[embed,%s]' % video_id,
|
|
||||||
video_id, 'Downloading embed page', fatal=False)
|
|
||||||
if embed_page:
|
|
||||||
media_id = self._search_regex(
|
|
||||||
(r'uol\.com\.br/(\d+)', r'mediaId=(\d+)'),
|
|
||||||
embed_page, 'media id', default=None)
|
|
||||||
|
|
||||||
if not media_id:
|
|
||||||
webpage = self._download_webpage(url, video_id)
|
|
||||||
media_id = self._search_regex(r'mediaId=(\d+)', webpage, 'media id')
|
|
||||||
|
|
||||||
video_data = self._download_json(
|
video_data = self._download_json(
|
||||||
'http://mais.uol.com.br/apiuol/v3/player/getMedia/%s.json' % media_id,
|
# https://api.mais.uol.com.br/apiuol/v4/player/data/[MEDIA_ID]
|
||||||
media_id)['item']
|
'https://api.mais.uol.com.br/apiuol/v3/media/detail/' + video_id,
|
||||||
|
video_id)['item']
|
||||||
|
media_id = compat_str(video_data['mediaId'])
|
||||||
title = video_data['title']
|
title = video_data['title']
|
||||||
|
ver = video_data.get('revision', 2)
|
||||||
|
|
||||||
query = {
|
uol_formats = self._download_json(
|
||||||
'ver': video_data.get('numRevision', 2),
|
'https://croupier.mais.uol.com.br/v3/formats/%s/jsonp' % media_id,
|
||||||
'r': 'http://mais.uol.com.br',
|
media_id)
|
||||||
}
|
quality = qualities(['mobile', 'WEBM', '360p', '720p', '1080p'])
|
||||||
for k in ('token', 'sign'):
|
|
||||||
v = video_data.get(k)
|
|
||||||
if v:
|
|
||||||
query[k] = v
|
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for f in video_data.get('formats', []):
|
for format_id, f in uol_formats.items():
|
||||||
|
if not isinstance(f, dict):
|
||||||
|
continue
|
||||||
f_url = f.get('url') or f.get('secureUrl')
|
f_url = f.get('url') or f.get('secureUrl')
|
||||||
if not f_url:
|
if not f_url:
|
||||||
continue
|
continue
|
||||||
|
query = {
|
||||||
|
'ver': ver,
|
||||||
|
'r': 'http://mais.uol.com.br',
|
||||||
|
}
|
||||||
|
for k in ('token', 'sign'):
|
||||||
|
v = f.get(k)
|
||||||
|
if v:
|
||||||
|
query[k] = v
|
||||||
f_url = update_url_query(f_url, query)
|
f_url = update_url_query(f_url, query)
|
||||||
format_id = str_or_none(f.get('id'))
|
format_id = format_id
|
||||||
if format_id == '10':
|
if format_id == 'HLS':
|
||||||
formats.extend(self._extract_m3u8_formats(
|
m3u8_formats = self._extract_m3u8_formats(
|
||||||
f_url, video_id, 'mp4', 'm3u8_native',
|
f_url, media_id, 'mp4', 'm3u8_native',
|
||||||
m3u8_id='hls', fatal=False))
|
m3u8_id='hls', fatal=False)
|
||||||
|
encoded_query = compat_urllib_parse_urlencode(query)
|
||||||
|
for m3u8_f in m3u8_formats:
|
||||||
|
m3u8_f['extra_param_to_segment_url'] = encoded_query
|
||||||
|
m3u8_f['url'] = update_url_query(m3u8_f['url'], query)
|
||||||
|
formats.extend(m3u8_formats)
|
||||||
continue
|
continue
|
||||||
fmt = {
|
formats.append({
|
||||||
'format_id': format_id,
|
'format_id': format_id,
|
||||||
'url': f_url,
|
'url': f_url,
|
||||||
'source_preference': 1,
|
'quality': quality(format_id),
|
||||||
}
|
'preference': -1,
|
||||||
fmt.update(self._FORMATS.get(format_id, {}))
|
})
|
||||||
formats.append(fmt)
|
self._sort_formats(formats)
|
||||||
self._sort_formats(formats, ('height', 'width', 'source_preference', 'tbr', 'ext'))
|
|
||||||
|
|
||||||
tags = []
|
tags = []
|
||||||
for tag in video_data.get('tags', []):
|
for tag in video_data.get('tags', []):
|
||||||
@ -148,12 +121,24 @@ class UOLIE(InfoExtractor):
|
|||||||
continue
|
continue
|
||||||
tags.append(tag_description)
|
tags.append(tag_description)
|
||||||
|
|
||||||
|
thumbnails = []
|
||||||
|
for q in ('Small', 'Medium', 'Wmedium', 'Large', 'Wlarge', 'Xlarge'):
|
||||||
|
q_url = video_data.get('thumb' + q)
|
||||||
|
if not q_url:
|
||||||
|
continue
|
||||||
|
thumbnails.append({
|
||||||
|
'id': q,
|
||||||
|
'url': q_url,
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': media_id,
|
'id': media_id,
|
||||||
'title': title,
|
'title': title,
|
||||||
'description': clean_html(video_data.get('desMedia')),
|
'description': clean_html(video_data.get('description')),
|
||||||
'thumbnail': video_data.get('thumbnail'),
|
'thumbnails': thumbnails,
|
||||||
'duration': int_or_none(video_data.get('durationSeconds')) or parse_duration(video_data.get('duration')),
|
'duration': parse_duration(video_data.get('duration')),
|
||||||
'tags': tags,
|
'tags': tags,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
|
'timestamp': parse_iso8601(video_data.get('publishDate'), ' '),
|
||||||
|
'view_count': int_or_none(video_data.get('viewsQtty')),
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ from ..compat import (
|
|||||||
)
|
)
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
clean_html,
|
clean_html,
|
||||||
|
ExtractorError,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
mimetype2ext,
|
mimetype2ext,
|
||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
@ -368,31 +369,47 @@ class YahooGyaOPlayerIE(InfoExtractor):
|
|||||||
'url': 'https://gyao.yahoo.co.jp/episode/%E3%81%8D%E3%81%AE%E3%81%86%E4%BD%95%E9%A3%9F%E3%81%B9%E3%81%9F%EF%BC%9F%20%E7%AC%AC2%E8%A9%B1%202019%2F4%2F12%E6%94%BE%E9%80%81%E5%88%86/5cb02352-b725-409e-9f8d-88f947a9f682',
|
'url': 'https://gyao.yahoo.co.jp/episode/%E3%81%8D%E3%81%AE%E3%81%86%E4%BD%95%E9%A3%9F%E3%81%B9%E3%81%9F%EF%BC%9F%20%E7%AC%AC2%E8%A9%B1%202019%2F4%2F12%E6%94%BE%E9%80%81%E5%88%86/5cb02352-b725-409e-9f8d-88f947a9f682',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
_GEO_BYPASS = False
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url).replace('/', ':')
|
video_id = self._match_id(url).replace('/', ':')
|
||||||
video = self._download_json(
|
headers = self.geo_verification_headers()
|
||||||
'https://gyao.yahoo.co.jp/dam/v1/videos/' + video_id,
|
headers['Accept'] = 'application/json'
|
||||||
video_id, query={
|
resp = self._download_json(
|
||||||
'fields': 'longDescription,title,videoId',
|
'https://gyao.yahoo.co.jp/apis/playback/graphql', video_id, query={
|
||||||
}, headers={
|
'appId': 'dj00aiZpPUNJeDh2cU1RazU3UCZzPWNvbnN1bWVyc2VjcmV0Jng9NTk-',
|
||||||
'X-User-Agent': 'Unknown Pc GYAO!/2.0.0 Web',
|
'query': '''{
|
||||||
})
|
content(parameter: {contentId: "%s", logicaAgent: PC_WEB}) {
|
||||||
|
video {
|
||||||
|
delivery {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
title
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}''' % video_id,
|
||||||
|
}, headers=headers)
|
||||||
|
content = resp['data']['content']
|
||||||
|
if not content:
|
||||||
|
msg = resp['errors'][0]['message']
|
||||||
|
if msg == 'not in japan':
|
||||||
|
self.raise_geo_restricted(countries=['JP'])
|
||||||
|
raise ExtractorError(msg)
|
||||||
|
video = content['video']
|
||||||
return {
|
return {
|
||||||
'_type': 'url_transparent',
|
'_type': 'url_transparent',
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': video['title'],
|
'title': video['title'],
|
||||||
'url': smuggle_url(
|
'url': smuggle_url(
|
||||||
'http://players.brightcove.net/4235717419001/SyG5P0gjb_default/index.html?videoId=' + video['videoId'],
|
'http://players.brightcove.net/4235717419001/SyG5P0gjb_default/index.html?videoId=' + video['delivery']['id'],
|
||||||
{'geo_countries': ['JP']}),
|
{'geo_countries': ['JP']}),
|
||||||
'description': video.get('longDescription'),
|
|
||||||
'ie_key': BrightcoveNewIE.ie_key(),
|
'ie_key': BrightcoveNewIE.ie_key(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class YahooGyaOIE(InfoExtractor):
|
class YahooGyaOIE(InfoExtractor):
|
||||||
IE_NAME = 'yahoo:gyao'
|
IE_NAME = 'yahoo:gyao'
|
||||||
_VALID_URL = r'https?://(?:gyao\.yahoo\.co\.jp/(?:p|title/[^/]+)|streaming\.yahoo\.co\.jp/p/y)/(?P<id>\d+/v\d+|[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})'
|
_VALID_URL = r'https?://(?:gyao\.yahoo\.co\.jp/(?:p|title(?:/[^/]+)?)|streaming\.yahoo\.co\.jp/p/y)/(?P<id>\d+/v\d+|[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://gyao.yahoo.co.jp/p/00449/v03102/',
|
'url': 'https://gyao.yahoo.co.jp/p/00449/v03102/',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
@ -405,6 +422,9 @@ class YahooGyaOIE(InfoExtractor):
|
|||||||
}, {
|
}, {
|
||||||
'url': 'https://gyao.yahoo.co.jp/title/%E3%81%97%E3%82%83%E3%81%B9%E3%81%8F%E3%82%8A007/5b025a49-b2e5-4dc7-945c-09c6634afacf',
|
'url': 'https://gyao.yahoo.co.jp/title/%E3%81%97%E3%82%83%E3%81%B9%E3%81%8F%E3%82%8A007/5b025a49-b2e5-4dc7-945c-09c6634afacf',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
|
}, {
|
||||||
|
'url': 'https://gyao.yahoo.co.jp/title/5b025a49-b2e5-4dc7-945c-09c6634afacf',
|
||||||
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
|
@ -426,6 +426,10 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||||||
(?(1).+)? # if we found the ID, everything can follow
|
(?(1).+)? # if we found the ID, everything can follow
|
||||||
$""" % {'playlist_id': YoutubeBaseInfoExtractor._PLAYLIST_ID_RE}
|
$""" % {'playlist_id': YoutubeBaseInfoExtractor._PLAYLIST_ID_RE}
|
||||||
_NEXT_URL_RE = r'[\?&]next_url=([^&]+)'
|
_NEXT_URL_RE = r'[\?&]next_url=([^&]+)'
|
||||||
|
_PLAYER_INFO_RE = (
|
||||||
|
r'/(?P<id>[a-zA-Z0-9_-]{8,})/player_ias\.vflset(?:/[a-zA-Z]{2,3}_[a-zA-Z]{2,3})?/base\.(?P<ext>[a-z]+)$',
|
||||||
|
r'\b(?P<id>vfl[a-zA-Z0-9_-]+)\b.*?\.(?P<ext>[a-z]+)$',
|
||||||
|
)
|
||||||
_formats = {
|
_formats = {
|
||||||
'5': {'ext': 'flv', 'width': 400, 'height': 240, 'acodec': 'mp3', 'abr': 64, 'vcodec': 'h263'},
|
'5': {'ext': 'flv', 'width': 400, 'height': 240, 'acodec': 'mp3', 'abr': 64, 'vcodec': 'h263'},
|
||||||
'6': {'ext': 'flv', 'width': 450, 'height': 270, 'acodec': 'mp3', 'abr': 64, 'vcodec': 'h263'},
|
'6': {'ext': 'flv', 'width': 450, 'height': 270, 'acodec': 'mp3', 'abr': 64, 'vcodec': 'h263'},
|
||||||
@ -1227,6 +1231,26 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||||||
'url': 'https://www.youtubekids.com/watch?v=3b8nCWDgZ6Q',
|
'url': 'https://www.youtubekids.com/watch?v=3b8nCWDgZ6Q',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
# invalid -> valid video id redirection
|
||||||
|
'url': 'DJztXj2GPfl',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'DJztXj2GPfk',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Panjabi MC - Mundian To Bach Ke (The Dictator Soundtrack)',
|
||||||
|
'description': 'md5:bf577a41da97918e94fa9798d9228825',
|
||||||
|
'upload_date': '20090125',
|
||||||
|
'uploader': 'Prochorowka',
|
||||||
|
'uploader_id': 'Prochorowka',
|
||||||
|
'uploader_url': r're:https?://(?:www\.)?youtube\.com/user/Prochorowka',
|
||||||
|
'artist': 'Panjabi MC',
|
||||||
|
'track': 'Beware of the Boys (Mundian to Bach Ke) - Motivo Hi-Lectro Remix',
|
||||||
|
'album': 'Beware of the Boys (Mundian To Bach Ke)',
|
||||||
|
},
|
||||||
|
'params': {
|
||||||
|
'skip_download': True,
|
||||||
|
},
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@ -1253,14 +1277,18 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||||||
""" Return a string representation of a signature """
|
""" Return a string representation of a signature """
|
||||||
return '.'.join(compat_str(len(part)) for part in example_sig.split('.'))
|
return '.'.join(compat_str(len(part)) for part in example_sig.split('.'))
|
||||||
|
|
||||||
def _extract_signature_function(self, video_id, player_url, example_sig):
|
@classmethod
|
||||||
id_m = re.match(
|
def _extract_player_info(cls, player_url):
|
||||||
r'.*?[-.](?P<id>[a-zA-Z0-9_-]+)(?:/watch_as3|/html5player(?:-new)?|(?:/[a-z]{2,3}_[A-Z]{2})?/base)?\.(?P<ext>[a-z]+)$',
|
for player_re in cls._PLAYER_INFO_RE:
|
||||||
player_url)
|
id_m = re.search(player_re, player_url)
|
||||||
if not id_m:
|
if id_m:
|
||||||
|
break
|
||||||
|
else:
|
||||||
raise ExtractorError('Cannot identify player %r' % player_url)
|
raise ExtractorError('Cannot identify player %r' % player_url)
|
||||||
player_type = id_m.group('ext')
|
return id_m.group('ext'), id_m.group('id')
|
||||||
player_id = id_m.group('id')
|
|
||||||
|
def _extract_signature_function(self, video_id, player_url, example_sig):
|
||||||
|
player_type, player_id = self._extract_player_info(player_url)
|
||||||
|
|
||||||
# Read from filesystem cache
|
# Read from filesystem cache
|
||||||
func_id = '%s_%s_%s' % (
|
func_id = '%s_%s_%s' % (
|
||||||
@ -1678,7 +1706,10 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||||||
|
|
||||||
# Get video webpage
|
# Get video webpage
|
||||||
url = proto + '://www.youtube.com/watch?v=%s&gl=US&hl=en&has_verified=1&bpctr=9999999999' % video_id
|
url = proto + '://www.youtube.com/watch?v=%s&gl=US&hl=en&has_verified=1&bpctr=9999999999' % video_id
|
||||||
video_webpage = self._download_webpage(url, video_id)
|
video_webpage, urlh = self._download_webpage_handle(url, video_id)
|
||||||
|
|
||||||
|
qs = compat_parse_qs(compat_urllib_parse_urlparse(urlh.geturl()).query)
|
||||||
|
video_id = qs.get('v', [None])[0] or video_id
|
||||||
|
|
||||||
# Attempt to extract SWF player URL
|
# Attempt to extract SWF player URL
|
||||||
mobj = re.search(r'swfConfig.*?"(https?:\\/\\/.*?watch.*?-.*?\.swf)"', video_webpage)
|
mobj = re.search(r'swfConfig.*?"(https?:\\/\\/.*?watch.*?-.*?\.swf)"', video_webpage)
|
||||||
@ -1986,22 +2017,10 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||||||
|
|
||||||
if self._downloader.params.get('verbose'):
|
if self._downloader.params.get('verbose'):
|
||||||
if player_url is None:
|
if player_url is None:
|
||||||
player_version = 'unknown'
|
|
||||||
player_desc = 'unknown'
|
player_desc = 'unknown'
|
||||||
else:
|
else:
|
||||||
if player_url.endswith('swf'):
|
player_type, player_version = self._extract_player_info(player_url)
|
||||||
player_version = self._search_regex(
|
player_desc = '%s player %s' % ('flash' if player_type == 'swf' else 'html5', player_version)
|
||||||
r'-(.+?)(?:/watch_as3)?\.swf$', player_url,
|
|
||||||
'flash player', fatal=False)
|
|
||||||
player_desc = 'flash player %s' % player_version
|
|
||||||
else:
|
|
||||||
player_version = self._search_regex(
|
|
||||||
[r'html5player-([^/]+?)(?:/html5player(?:-new)?)?\.js',
|
|
||||||
r'(?:www|player(?:_ias)?)[-.]([^/]+)(?:/[a-z]{2,3}_[A-Z]{2})?/base\.js'],
|
|
||||||
player_url,
|
|
||||||
'html5 player', fatal=False)
|
|
||||||
player_desc = 'html5 player %s' % player_version
|
|
||||||
|
|
||||||
parts_sizes = self._signature_cache_id(encrypted_sig)
|
parts_sizes = self._signature_cache_id(encrypted_sig)
|
||||||
self.to_screen('{%s} signature length %s, %s' %
|
self.to_screen('{%s} signature length %s, %s' %
|
||||||
(format_id, parts_sizes, player_desc))
|
(format_id, parts_sizes, player_desc))
|
||||||
|
@ -7,6 +7,7 @@ import base64
|
|||||||
import binascii
|
import binascii
|
||||||
import calendar
|
import calendar
|
||||||
import codecs
|
import codecs
|
||||||
|
import collections
|
||||||
import contextlib
|
import contextlib
|
||||||
import ctypes
|
import ctypes
|
||||||
import datetime
|
import datetime
|
||||||
@ -30,6 +31,7 @@ import ssl
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
import xml.etree.ElementTree
|
import xml.etree.ElementTree
|
||||||
import zlib
|
import zlib
|
||||||
@ -2735,14 +2737,66 @@ class YoutubeDLCookieJar(compat_cookiejar.MozillaCookieJar):
|
|||||||
1. https://curl.haxx.se/docs/http-cookies.html
|
1. https://curl.haxx.se/docs/http-cookies.html
|
||||||
"""
|
"""
|
||||||
_HTTPONLY_PREFIX = '#HttpOnly_'
|
_HTTPONLY_PREFIX = '#HttpOnly_'
|
||||||
|
_ENTRY_LEN = 7
|
||||||
|
_HEADER = '''# Netscape HTTP Cookie File
|
||||||
|
# This file is generated by youtube-dl. Do not edit.
|
||||||
|
|
||||||
|
'''
|
||||||
|
_CookieFileEntry = collections.namedtuple(
|
||||||
|
'CookieFileEntry',
|
||||||
|
('domain_name', 'include_subdomains', 'path', 'https_only', 'expires_at', 'name', 'value'))
|
||||||
|
|
||||||
def save(self, filename=None, ignore_discard=False, ignore_expires=False):
|
def save(self, filename=None, ignore_discard=False, ignore_expires=False):
|
||||||
|
"""
|
||||||
|
Save cookies to a file.
|
||||||
|
|
||||||
|
Most of the code is taken from CPython 3.8 and slightly adapted
|
||||||
|
to support cookie files with UTF-8 in both python 2 and 3.
|
||||||
|
"""
|
||||||
|
if filename is None:
|
||||||
|
if self.filename is not None:
|
||||||
|
filename = self.filename
|
||||||
|
else:
|
||||||
|
raise ValueError(compat_cookiejar.MISSING_FILENAME_TEXT)
|
||||||
|
|
||||||
# Store session cookies with `expires` set to 0 instead of an empty
|
# Store session cookies with `expires` set to 0 instead of an empty
|
||||||
# string
|
# string
|
||||||
for cookie in self:
|
for cookie in self:
|
||||||
if cookie.expires is None:
|
if cookie.expires is None:
|
||||||
cookie.expires = 0
|
cookie.expires = 0
|
||||||
compat_cookiejar.MozillaCookieJar.save(self, filename, ignore_discard, ignore_expires)
|
|
||||||
|
with io.open(filename, 'w', encoding='utf-8') as f:
|
||||||
|
f.write(self._HEADER)
|
||||||
|
now = time.time()
|
||||||
|
for cookie in self:
|
||||||
|
if not ignore_discard and cookie.discard:
|
||||||
|
continue
|
||||||
|
if not ignore_expires and cookie.is_expired(now):
|
||||||
|
continue
|
||||||
|
if cookie.secure:
|
||||||
|
secure = 'TRUE'
|
||||||
|
else:
|
||||||
|
secure = 'FALSE'
|
||||||
|
if cookie.domain.startswith('.'):
|
||||||
|
initial_dot = 'TRUE'
|
||||||
|
else:
|
||||||
|
initial_dot = 'FALSE'
|
||||||
|
if cookie.expires is not None:
|
||||||
|
expires = compat_str(cookie.expires)
|
||||||
|
else:
|
||||||
|
expires = ''
|
||||||
|
if cookie.value is None:
|
||||||
|
# cookies.txt regards 'Set-Cookie: foo' as a cookie
|
||||||
|
# with no name, whereas http.cookiejar regards it as a
|
||||||
|
# cookie with no value.
|
||||||
|
name = ''
|
||||||
|
value = cookie.name
|
||||||
|
else:
|
||||||
|
name = cookie.name
|
||||||
|
value = cookie.value
|
||||||
|
f.write(
|
||||||
|
'\t'.join([cookie.domain, initial_dot, cookie.path,
|
||||||
|
secure, expires, name, value]) + '\n')
|
||||||
|
|
||||||
def load(self, filename=None, ignore_discard=False, ignore_expires=False):
|
def load(self, filename=None, ignore_discard=False, ignore_expires=False):
|
||||||
"""Load cookies from a file."""
|
"""Load cookies from a file."""
|
||||||
@ -2752,12 +2806,30 @@ class YoutubeDLCookieJar(compat_cookiejar.MozillaCookieJar):
|
|||||||
else:
|
else:
|
||||||
raise ValueError(compat_cookiejar.MISSING_FILENAME_TEXT)
|
raise ValueError(compat_cookiejar.MISSING_FILENAME_TEXT)
|
||||||
|
|
||||||
cf = io.StringIO()
|
def prepare_line(line):
|
||||||
with open(filename) as f:
|
|
||||||
for line in f:
|
|
||||||
if line.startswith(self._HTTPONLY_PREFIX):
|
if line.startswith(self._HTTPONLY_PREFIX):
|
||||||
line = line[len(self._HTTPONLY_PREFIX):]
|
line = line[len(self._HTTPONLY_PREFIX):]
|
||||||
cf.write(compat_str(line))
|
# comments and empty lines are fine
|
||||||
|
if line.startswith('#') or not line.strip():
|
||||||
|
return line
|
||||||
|
cookie_list = line.split('\t')
|
||||||
|
if len(cookie_list) != self._ENTRY_LEN:
|
||||||
|
raise compat_cookiejar.LoadError('invalid length %d' % len(cookie_list))
|
||||||
|
cookie = self._CookieFileEntry(*cookie_list)
|
||||||
|
if cookie.expires_at and not cookie.expires_at.isdigit():
|
||||||
|
raise compat_cookiejar.LoadError('invalid expires at %s' % cookie.expires_at)
|
||||||
|
return line
|
||||||
|
|
||||||
|
cf = io.StringIO()
|
||||||
|
with io.open(filename, encoding='utf-8') as f:
|
||||||
|
for line in f:
|
||||||
|
try:
|
||||||
|
cf.write(prepare_line(line))
|
||||||
|
except compat_cookiejar.LoadError as e:
|
||||||
|
write_string(
|
||||||
|
'WARNING: skipping cookie file entry due to %s: %r\n'
|
||||||
|
% (e, line), sys.stderr)
|
||||||
|
continue
|
||||||
cf.seek(0)
|
cf.seek(0)
|
||||||
self._really_load(cf, filename, ignore_discard, ignore_expires)
|
self._really_load(cf, filename, ignore_discard, ignore_expires)
|
||||||
# Session cookies are denoted by either `expires` field set to
|
# Session cookies are denoted by either `expires` field set to
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
__version__ = '2020.03.24'
|
__version__ = '2020.05.03'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user