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

plugins.tf1: implement authentication #5983

Merged
merged 1 commit into from May 17, 2024

Conversation

BellezaEmporium
Copy link
Contributor

@BellezaEmporium BellezaEmporium commented May 9, 2024

Resolves #5379

This PR is aimed to provide authentification basis for the website TF1.fr. A step forward would be to check the user subscriptions, as now certain streams might be pay-per-view, under the TF1MAX subscription plan. The answer is the same as if you're not logged in, will answer "Permission insuffisante".

With recommendations from @bastimeyer earlier on, on issue 5379, I've rewrote the plugin to make sure it suits the standards.

Copy link
Member

@bastimeyer bastimeyer left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.

I'm just going to comment on the code. I currently don't have time to check the site and validate your plugin changes, including anything related to authentication and HTTP requests+responses.

There are also tons of linting issues which you'll have to fix. Please have a look at this short guide:
https://streamlink.github.io/developing.html

Also one question since I'm unaware of the account restrictions: the plugin covers multiple sites. Is authentication required for of them?

src/streamlink/plugins/tf1.py Outdated Show resolved Hide resolved
src/streamlink/plugins/tf1.py Outdated Show resolved Hide resolved
src/streamlink/plugins/tf1.py Outdated Show resolved Hide resolved
src/streamlink/plugins/tf1.py Outdated Show resolved Hide resolved
src/streamlink/plugins/tf1.py Outdated Show resolved Hide resolved
src/streamlink/plugins/tf1.py Outdated Show resolved Hide resolved
src/streamlink/plugins/tf1.py Outdated Show resolved Hide resolved
src/streamlink/plugins/tf1.py Outdated Show resolved Hide resolved
src/streamlink/plugins/tf1.py Outdated Show resolved Hide resolved
src/streamlink/plugins/tf1.py Outdated Show resolved Hide resolved
@bastimeyer bastimeyer added the plugin issue A Plugin does not work correctly label May 9, 2024
@bastimeyer bastimeyer changed the title plugin.tf1: implement authentification plugins.tf1: implement authentication May 9, 2024
@BellezaEmporium
Copy link
Contributor Author

BellezaEmporium commented May 9, 2024

Thanks for the comments. I'll get through them one by one and fix the necessary issues.

As for the current restrictions, tf1.fr contains all channels from their group (TF1, TMC, TFX, LCI, TF1 Séries Films, except TV Breizh.) and some other FAST channels created for their occasions.

image

All of them right now needs to have an IP located in France and a valid account to get access to their streams.

@BellezaEmporium
Copy link
Contributor Author

BellezaEmporium commented May 15, 2024

I've rewrote the plugin based on your recommendations. Last commit should reflect all required changes.

Co-Authored-By: bastimeyer <mail@bastimeyer.de>
@bastimeyer
Copy link
Member

bastimeyer commented May 17, 2024

I force-pushed onto your PR branch because I decided to clean up the remaining issues myself and make a couple more changes.

  • Fixed linting and code style issues
  • Fixed missing $account plugin-metadata
  • Fixed error handling
  • Fixed validation schemas
  • Fixed auth logic issues
  • Renamed --tf1-username to --tf1-email
  • Added token caching and --tf1-purge-credentials

Authentication is only required on tf1.fr. The other sites work fine, even without a French IP address:

$ streamlink https://tf1info.fr/direct/ best
[cli][info] Found matching plugin tf1 for URL https://tf1info.fr/direct/
[cli][info] Available streams: 234p (worst), 360p, 576p_alt, 576p, 720p (best)
[cli][info] Opening stream: 720p (hls-multi)
[cli][info] Starting player: /usr/bin/mpv
[utils.named_pipe][info] Creating pipe streamlinkpipe-153664-1-5029
[utils.named_pipe][info] Creating pipe streamlinkpipe-153664-2-3929
[cli][info] Player closed
[cli][info] Stream ended
[cli][info] Closing currently open stream...

$ streamlink https://www.lci.fr/direct best
[cli][info] Found matching plugin tf1 for URL https://www.lci.fr/direct
[cli][info] Available streams: 234p (worst), 360p, 576p_alt, 576p, 720p (best)
[cli][info] Opening stream: 720p (hls-multi)
[cli][info] Starting player: /usr/bin/mpv
[utils.named_pipe][info] Creating pipe streamlinkpipe-153955-1-8455
[utils.named_pipe][info] Creating pipe streamlinkpipe-153955-2-2202
[cli][info] Player closed
[cli][info] Stream ended
[cli][info] Closing currently open stream...

New token with throwaway-account:

$ streamlink https://www.tf1.fr/tf1/direct best --http-proxy socks5h://localhost:1920 --tf1-email ogbeyafi@email1.io --tf1-password Qwerty123456789!
[cli][info] Found matching plugin tf1 for URL https://www.tf1.fr/tf1/direct
[plugins.tf1][info] Acquiring new user-authentication token...
[cli][info] Available streams: 234p (worst), 360p, 576p_alt, 576p, 720p (best)
[cli][info] Opening stream: 720p (hls-multi)
[cli][info] Starting player: /usr/bin/mpv
[utils.named_pipe][info] Creating pipe streamlinkpipe-154141-1-4629
[utils.named_pipe][info] Creating pipe streamlinkpipe-154141-2-6526
[cli][info] Player closed
[cli][info] Stream ended
[cli][info] Closing currently open stream...

Cached token:

$ streamlink https://www.tf1.fr/tf1/direct best --http-proxy socks5h://localhost:1920
[cli][info] Found matching plugin tf1 for URL https://www.tf1.fr/tf1/direct
[cli][info] Available streams: 234p (worst), 360p, 576p_alt, 576p, 720p (best)
[cli][info] Opening stream: 720p (hls-multi)
[cli][info] Starting player: /usr/bin/mpv
[utils.named_pipe][info] Creating pipe streamlinkpipe-154271-1-2504
[utils.named_pipe][info] Creating pipe streamlinkpipe-154271-2-3907
[cli][info] Player closed
[cli][info] Stream ended
[cli][info] Closing currently open stream...

$ streamlink https://www.tf1.fr/stream/chante-69061019 best --http-proxy socks5h://localhost:1920
[cli][info] Found matching plugin tf1 for URL https://www.tf1.fr/stream/chante-69061019
[cli][info] Available streams: 234p (worst), 270p, 360p, 576p (best)
[cli][info] Opening stream: 576p (hls-multi)
[cli][info] Starting player: /usr/bin/mpv
[utils.named_pipe][info] Creating pipe streamlinkpipe-154476-1-4314
[utils.named_pipe][info] Creating pipe streamlinkpipe-154476-2-3647
[cli][info] Player closed
[cli][info] Stream ended
[cli][info] Closing currently open stream...

Invalid auth data:

$ streamlink https://www.tf1.fr/tf1/direct best --http-proxy socks5h://localhost:1920 --tf1-purge-credentials --tf1-email ogbeyafi@email1.io --tf1-password invalid
[cli][info] Found matching plugin tf1 for URL https://www.tf1.fr/tf1/direct
[plugins.tf1][info] Removing cached user-authentication token...
[plugins.tf1][info] Acquiring new user-authentication token...
error: error_code=403042 - invalid loginID or password

Geo-blocked access

$ streamlink https://www.tf1.fr/tf1/direct best --tf1-email ogbeyafi@email1.io --tf1-password Qwerty123456789!
[cli][info] Found matching plugin tf1 for URL https://www.tf1.fr/tf1/direct
[plugins.tf1][info] Acquiring new user-authentication token...
[plugins.tf1][error] Désolé, cette vidéo n'est pas accessible depuis votre zone géographique
error: No playable streams found on this URL: https://www.tf1.fr/tf1/direct

@bastimeyer
Copy link
Member

The cache currently doesn't set an expiration time/date, but it's not really important...

Going to merge this now.

@bastimeyer bastimeyer merged commit 7adb5b1 into streamlink:master May 17, 2024
23 checks passed
@BellezaEmporium BellezaEmporium deleted the patch-1 branch May 18, 2024 09:35
@BellezaEmporium
Copy link
Contributor Author

Perfect, thanks for going further in this PR. Interesting, thought they would enforce it everywhere. I consider myself corrected.

@octavioj
Copy link

octavioj commented May 18, 2024

This is wonderful. Which version of streamlink will have this modification, if I may ask?

@bastimeyer
Copy link
Member

6.7.4+1.g7adb5b12
https://github.com/streamlink/streamlink/commits/master/

@octavioj
Copy link

Thank you.

@campones
Copy link

campones commented May 18, 2024

I tested few hours ago the beta release from yesterday, works perfectly

well not the beta release, the nightly build

@octavioj
Copy link

It works wonderfully with liveproxy too. Excellent.

@campones
Copy link

@octavioj sorry for the off topic but what's the point to use this liveproxy exactly?

@BellezaEmporium
Copy link
Contributor Author

That's not the correct place to talk about this I believe.

@campones
Copy link

probably not. anyway, good job guys, has been quite a long way but result is outstanding ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin issue A Plugin does not work correctly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

plugins.tf1: Permission insuffisante
4 participants