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

[extractor/dplay] GlobalCyclingNetworkPlus: Add extractor #7360

Merged
merged 1 commit into from Jun 22, 2023

Conversation

bashonly
Copy link
Member

@bashonly bashonly commented Jun 20, 2023

Subscription-only site for cycling videos/events. Uses the Discovery+/dplay API.

Closes #7324

Template

Before submitting a pull request make sure you have:

In order to be accepted and merged into yt-dlp each piece of code must be in public domain or released under Unlicense. Check all of the following options that apply:

  • 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?

Copilot Summary

🤖 Generated by Copilot at 9c13de0

Summary

🚴‍♂️🔐🌎

Add support for Global Cycling Network Plus videos using the Discovery Plus API. Create a new extractor class GlobalCyclingNetworkPlusIE in dplay.py and register it in _extractors.py.

To watch cycling videos with ease
You can use GlobalCyclingNetworkPlusIE
It's a new extractor class
That uses the dplay pass
And lets you geo-bypass with a country key

Walkthrough

  • Add extractor for Global Cycling Network Plus videos (link, link)
  • Allow overriding country code for Discovery Plus API requests (link)

@bashonly bashonly added the site-request Request to support a new website label Jun 20, 2023
@@ -65,6 +65,7 @@ def _download_video_playback_info(self, disco_base, video_id, headers):
return streaming_list

def _get_disco_api_info(self, url, display_id, disco_host, realm, country, domain=''):
country = self.get_param('geo_bypass_country') or country
Copy link
Member Author

Choose a reason for hiding this comment

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

Since this a worldwide site, it doesn't make sense to hardcode a country, as is required in the _DISCO_API_PARAMS var for extractors subclassed from DiscoveryPlusBaseIE:

_DISCO_API_PARAMS = {
'disco_host': 'disco-api-prod.globalcyclingnetwork.com',
'realm': 'gcn',
'country': 'us',
}

With the change to _get_disco_api_info, the user can use --geo-bypass-country to set their country param (and DPlayBaseIE also uses this country value for xff anyways).

Letting the user configure the country param would also partially address problems reported in #2138 and #2361 (though completely resolving those issues is outside the scope of this PR), see:
#2361 (comment)
#2138 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

But the disco_host may also vary by country (perhaps not in this case)?

Copy link
Member Author

Choose a reason for hiding this comment

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

it did not vary for this site; that's something we can deal with when the extractor at hand demands it

@bashonly bashonly merged commit 774aa09 into yt-dlp:master Jun 22, 2023
12 checks passed
def _update_disco_api_headers(self, headers, disco_base, display_id, realm):
headers.update({
'x-disco-params': f'realm={realm}',
'x-disco-client': f'WEB:UNKNOWN:{self._PRODUCT}:27.3.2',
Copy link
Contributor

Choose a reason for hiding this comment

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

27.42 has been observed for other D/D+ sites. I wonder if this has any effect. One could guess that eventually the site could exclude a "too old" client, but also might not like a "too new" one.

Copy link
Member Author

Choose a reason for hiding this comment

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

27.3.2 is what was in the requests my browser was sending

@bashonly bashonly deleted the extractor/gcn branch July 2, 2023 16:39
aalsuwaidi pushed a commit to aalsuwaidi/yt-dlp that referenced this pull request Apr 21, 2024
* Allows `country` API param to be configured with `--xff`/`geo_bypass_country`

Closes yt-dlp#7324
Authored by: bashonly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
site-request Request to support a new website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GCN (global cycling network)
2 participants