Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Spectrum as an Adobe Pass provider #26792

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kevinoconnor7
Copy link
Contributor

@kevinoconnor7 kevinoconnor7 commented Oct 3, 2020

Before submitting a pull request make sure you have:

In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:

  • I am the original author of this code and I am willing to release it under Unlicense
  • I am not the original author of this code but it is in public domain or released under Unlicense (provide reliable evidence)

What is the purpose of your pull request?

  • Bug fix
  • Improvement
  • New extractor
  • New feature

Description of your pull request and other information

Some services no longer allow for the older services (ex. Charter_Direct) to be used and just return a generic 401 response.
Going through their login flow manually, the new provider name appears to be Spectrum. This provider seems to work even place of services that still allow for Charter_Direct to be used.

@gxam
Copy link

gxam commented Dec 21, 2020

I patched 2020.12.14 with this, but it does not work:

[debug] System config: []
[debug] User config: ['--write-thumbnail', '--add-metadata', '--cookies', '~/.youtube-dl.cookies', '--download-archive', '~/.youtube-dl.archive', '--ap-mso', 'Spectrum', '--ap-username', 'PRIVATE', '--ap-password', 'PRIVATE', '--verbose', '--write-info-json']
[debug] Custom config: []
[debug] Command-line args: ['https://play.mylifetime.com/movies/dear-christmas/full-movie']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2020.12.14
[debug] Python version 3.9.1 (CPython) - macOS-10.15.7-x86_64-i386-64bit
[debug] exe versions: ffmpeg git-2020-11-22-9208b72, ffprobe git-2020-11-22-9208b72, rtmpdump 2.4
[debug] Proxy map: {}
[aenetworks] movies/dear-christmas/full-movie: Downloading JSON metadata
[aenetworks] 1823671875968: Downloading JSON metadata
[aenetworks] 1823671875968: Downloading Provider Redirect Page
[aenetworks] 1823671875968: Downloading Provider Login Page
ERROR: Unable to extract post url; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/youtube_dl/YoutubeDL.py", line 803, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/youtube_dl/YoutubeDL.py", line 824, in __extract_info
    ie_result = ie.extract(url)
  File "/usr/local/lib/python3.9/site-packages/youtube_dl/extractor/common.py", line 532, in extract
    ie_result = self._real_extract(url)
  File "/usr/local/lib/python3.9/site-packages/youtube_dl/extractor/aenetworks.py", line 158, in _real_extract
    auth = self._extract_mvpd_auth(
  File "/usr/local/lib/python3.9/site-packages/youtube_dl/extractor/adobepass.py", line 1509, in _extract_mvpd_auth
    provider_refresh_redirect_url = extract_redirect_url(
  File "/usr/local/lib/python3.9/site-packages/youtube_dl/extractor/adobepass.py", line 1370, in post_form
    post_url = self._html_search_regex(r'<form[^>]+action=(["\'])(?P<url>.+?)\1', form_page, 'post url', group='url')
  File "/usr/local/lib/python3.9/site-packages/youtube_dl/extractor/common.py", line 1019, in _html_search_regex
    res = self._search_regex(pattern, string, name, default, fatal, flags, group)
  File "/usr/local/lib/python3.9/site-packages/youtube_dl/extractor/common.py", line 1010, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
youtube_dl.utils.RegexNotFoundError: Unable to extract post url; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

I threw in a breakpoint to investigate. provider_login_page_res at adobepass.py:1514 is basically just javascript, no form in the HTML:

'<!DOCTYPE html><html lang="en"><head>\n    <meta charset="UTF-8">\n    <meta name="viewport" content="width=device-width, initial-scale=1.0">\n    <meta http-equiv="X-UA-Compatible" content="ie=edge">\n    <title>TV Everywhere</title>\n    <meta http-equiv="Cache-Control" content="max-age=0, no-cache, no-store, must-revalidate">\n    <meta http-equiv="Pragma" content="no-cache">\n    <meta http-equiv="Expires" content="0">\n    <script language="JavaScript" type="text/javascript">\n        const __MIN__ = \'.min\';\n    </script>\n\n    <script type="text/javascript">\n        // IE 11 polyfills\n        !function( d ) {\n            if( !d.currentScript ){\n                var s = d.createElement( \'script\' );\n                s.src = \'https://polyfill.io/v3/polyfill.js?flags=gated&features=default%2Ces2015%2Ces5%2Ces6%2Ces7%2CObject.entries%2CArray.prototype.find%2CArray.from%2CObject.values\';\n                d.head.appendChild( s );\n            }\n        }(document)\n    </script>\n\n      <script language="JavaScript" type="text/javascript">\n          const RelayState = "...";\n          const SAMLRequest = "...";\n      </script>\n    </head>\n<body id="temporary-override" class="kite-theme-dark">\n    <div id="root"></div>\n<script type="text/javascript" src="/vendor.b7f691fb52892f76e249.chunk.js"></script><script type="text/javascript" src="/app.b7f691fb52892f76e249.bundle.js"></script>\n\n</body></html>'

I redacted RelayState and SAMLRequest assuming they contained authentication tokens or something.

I can't tell what, if anything, in this pile of JS contains the URL adobepass is looking for.

@kevinoconnor7
Copy link
Contributor Author

Hmm yeah looks like Spectrum updated their login page recently. I'll dig into it.

@kevinoconnor7
Copy link
Contributor Author

Reworked the change to get things working again. Unfortunately the new login form is a bit special as it's all dynamically loaded via JS so we need to manually recreate the flow in code.

@gxam
Copy link

gxam commented Dec 22, 2020

Awesome, nbc and aenetworks are both working for me now. This fixes both #22714 and #27328

@kevinoconnor7
Copy link
Contributor Author

@dstftw Do you need me to send a provider account?

@dstftw
Copy link
Collaborator

dstftw commented Jan 16, 2021

Yes.

@kevinoconnor7
Copy link
Contributor Author

Unfortunately my Spectrum account is in a weird state and is not allowing me to change my password. Can someone else (@gxam maybe?) share a login with @dstftw?

@ohmybahgosh
Copy link

ohmybahgosh commented Jun 28, 2021

If a dev needs a spectrum account login, please let me know and I'll provide one post-haste!

@dstftw let me know if this is something you're still interested in fixing, and if so, I'll send over the login for spectrum

@ohmybahgosh
Copy link

Bumping this.. If a developer could finish this update for the SPECTRUM MSO I'd be super grateful!

I have credentials that I will send immediately to whomever is a developer willing to take this on.

@ohmybahgosh
Copy link

@dstftw @kevinoconnor7 any willingness to work on this? I can provide MSO login

@kevinoconnor7
Copy link
Contributor Author

@ohmybahgosh All the work is done. From my perspective this PR is ready to merge. @dstftw just needs a Spectrum login to test it with. You can probably send it to them via the email on their github profile.

Unfortunately my Spectrum account is still in a bad state and I cannot easily change the password on it.

@ohmybahgosh
Copy link

ohmybahgosh commented Jul 5, 2021

Python 2.7.18

./youtube-dl/youtube-dl https://www.nbc.com/making-it/video/random-crafts-of-kindness/4386591 --verbose 
[debug] System config: []
[debug] User config: [u'--ap-mso', u'Spectrum', u'--ap-username', u'PRIVATE', u'--ap-password', u'PRIVATE', u'--convert-subtitles=srt', u'--add-metadata', u'--write-all-thumbnails', u'--embed-thumbnail', u'--embed-subs']
[debug] Custom config: []
[debug] Command-line args: [u'https://www.nbc.com/making-it/video/random-crafts-of-kindness/4386591', u'--verbose']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2021.03.14
[debug] Python version 2.7.18 (CPython) - Linux-5.10.0-kali9-amd64-x86_64-with-debian-kali-rolling
[debug] exe versions: ffmpeg 4.3.2-0, ffprobe 4.3.2-0, phantomjs 1.9.7, rtmpdump 2.4
[debug] Proxy map: {}
[NBC] 4386591: Downloading JSON metadata
[NBC] 4386591: Downloading Provider Redirect Page
[NBC] 4386591: Downloading Provider Login Page
[NBC] 4386591: Downloading SAML Response
ERROR: Unable to download JSON metadata: HTTP Error 404:  (caused by HTTPError()); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
  File "./youtube-dl/youtube-dl/youtube_dl/extractor/common.py", line 634, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "./youtube-dl/youtube-dl/youtube_dl/YoutubeDL.py", line 2279, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib/python2.7/urllib2.py", line 435, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 548, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 473, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 556, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)

Python 3.9.2

✦ ❯ ./youtube-dl https://www.nbc.com/making-it/video/random-crafts-of-kindness/4386591 --verbose --cookies /root/.cookies/nbc.txt                                                         [debug] System config: []
[debug] User config: ['--ap-mso', 'Spectrum', '--ap-username', 'PRIVATE', '--ap-password', 'PRIVATE', '--convert-subtitles=srt', '--add-metadata', '--write-all-thumbnails', '--embed-thumbnail', '--embed-subs']
[debug] Custom config: []
[debug] Command-line args: ['https://www.nbc.com/making-it/video/random-crafts-of-kindness/4386591', '--verbose', '--cookies', '/root/.cookies/nbc.txt']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2021.03.14
[debug] Python version 3.9.2 (CPython) - Linux-5.10.0-kali9-amd64-x86_64-with-glibc2.31
[debug] exe versions: ffmpeg 4.3.2-0, ffprobe 4.3.2-0, phantomjs 1.9.7, rtmpdump 2.4
[debug] Proxy map: {}
[NBC] 4386591: Downloading JSON metadata
[NBC] 4386591: Downloading Provider Redirect Page
[NBC] 4386591: Downloading Provider Login Page
[NBC] 4386591: Downloading SAML Response
ERROR: Unable to download JSON metadata: HTTP Error 404:  (caused by <HTTPError 404: ''>); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
  File "/opt/VID_TOOLZ/youtube-dl/./youtube-dl/youtube_dl/extractor/common.py", line 634, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/opt/VID_TOOLZ/youtube-dl/./youtube-dl/youtube_dl/YoutubeDL.py", line 2279, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/usr/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.9/urllib/request.py", line 561, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)

Some services no longer allow for the older services (ex.
`Charter_Direct`) to be used and just return a generic 401 response.
Going through their login flow manually, the new provider name appears to
be `Spectrum`. This provider seems to work even place of services that
still allow for `Charter_Direct` to be used.

The Spectrum login form also needs special handling since it's
dynamically loaded via JS thus we cannot simply capture the POST url and
hidden form fields. Instead we need to hardcode the POST URL and
recreate the request manually. Thankfully the SAMLRequest and RelayState
are in the HTML response.
@kevinoconnor7
Copy link
Contributor Author

oops! There was a case-sensitivity issue in the entitlement URL that I fixed on my local branch but never pushed. Should be fixed now!

@ohmybahgosh
Copy link

That fixed it!!

Copy link

@ohmybahgosh ohmybahgosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes case sensitivity issue, and now the Spectrum Ap-mso is fully functional!

pukkandan pushed a commit to yt-dlp/yt-dlp that referenced this pull request Jul 6, 2021
From: ytdl-org/youtube-dl#26792

Co-authored by: kevinoconnor7, ohmybahgosh
@jr1221
Copy link

jr1221 commented Jul 8, 2021

Are the devs reviewing this PR? Spectrum is one of the most popular TV providers in the U.S., this is a great addition! I have tested by using yt-dlp and it has worked so far, fixing unable to extract post url on NBC.

@ohmybahgosh
Copy link

Are the devs reviewing this PR? Spectrum is one of the most popular TV providers in the U.S., this is a great addition! I have tested by using yt-dlp and it has worked so far, fixing unable to extract post url on NBC.

I hope they are...

I issued a PR for this fix over on YT-DLP and it was tested/merged already. Has been working great!

nixxo pushed a commit to nixxo/yt-dlp that referenced this pull request Nov 22, 2021
From: ytdl-org/youtube-dl#26792

Co-authored by: kevinoconnor7, ohmybahgosh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants