chrippa / livestreamer

Command-line utility that extracts streams from various services and pipes them into a video player of choice. No longer maintained, use streamlink or youtube-dl instead.
http://livestreamer.io/
BSD 2-Clause "Simplified" License
3.88k stars 580 forks source link

Twitch - Unable to open URL #1478

Open X-Looper opened 8 years ago

X-Looper commented 8 years ago

Is anyone else experiencing problems watching Streams on Twitch with Livestreamer right now?

It was working just fine yesterday and now I'm getting the following error message while trying to watch any/all Streams:

error: Unable to open URL: https://api.twitch.tv/api/channels/channel_name/access_token.json <400 Client Error: Bad Request>

cbirchinger commented 8 years ago

See #1456

mooseh commented 8 years ago

The api is down at the moment, not matter what request you send its returning 400 no client id specified, im using OAuth and I am specifying a client id - confirmed http://twitchstatus.com/

X-Looper commented 8 years ago

Thanks for the input guys, appreciated!

Baerht commented 8 years ago

https://www.reddit.com/r/Twitch/comments/52ta5d/twitch_api_clientid_enforcement_is_now_live_what/

mjevans commented 8 years ago

This guide is a little better (also on Reddit, and I think linked from the thing Baerht posted)

https://www.reddit.com/r/Twitch/comments/52sye3/livestreamer_help_please_help/d7n0j36

Edit:

Also, how is Twitch doing 'not logged in' users? Are they forcing everyone to sign up now?

LoneFox78 commented 8 years ago

Also, how is Twitch doing 'not logged in' users? Are they forcing everyone to sign up now?

There are two kinds of tokens, client-specific and user-specific. You need only one of them. For example, livestreamer --http-header Client-ID=jzkbprff40iqj646a697cyrvl0zt2m6 works (It is the token used by their own web player).

hodor22 commented 8 years ago

this workarround helped me to make it work again https://www.reddit.com/r/Twitch/comments/52sye3/livestreamer_help_please_help/d7n0j36 thax@mjevans

steven7851 commented 8 years ago

@LoneFox78 Add http-header is working fine for me, and livestreamer's client-id is "ewvlchtxgqq88ru9gmfp1gmyt6h2b93". Find it at livestreamer_cli/main.py#L534.

CowCowCowCow commented 8 years ago

@LoneFox78 This works great via a terminal but I can't get it working from livestreamerrc. Any ideas? Thank you

skulblakka commented 8 years ago

Are you sure? You should be able to use all command line options as a option in the config file.

LoneFox78 commented 8 years ago

I don't really know python, but I got this working based on what youtube-dl does:

diff -bur livestreamer-20160315-orig/src/livestreamer/plugins/twitch.py livestreamer-20160315/src/livestreamer/plugins/twitch.py
--- livestreamer-20160315-orig/src/livestreamer/plugins/twitch.py   2016-03-15 06:28:45.000000000 +0200
+++ livestreamer-20160315/src/livestreamer/plugins/twitch.py    2016-09-15 20:56:25.000000000 +0300
@@ -27,6 +27,8 @@
 }

+TWITCH_CLIENT_ID="ewvlchtxgqq88ru9gmfp1gmyt6h2b93"
+
 _url_re = re.compile(r"""
     http(s)?://
     (?:
@@ -171,7 +173,7 @@
         url = "https://{0}.twitch.tv{1}.{2}".format(self.subdomain, path, format)

         # The certificate used by Twitch cannot be verified on some OpenSSL versions.
-        res = http.get(url, params=params, verify=False)
+        res = http.get(url, params=params, verify=False, headers={'Client-ID': TWITCH_CLIENT_ID})

         if format == "json":
             return http.json(res, schema=schema)
diff -bur livestreamer-20160315-orig/src/livestreamer_cli/main.py livestreamer-20160315/src/livestreamer_cli/main.py
--- livestreamer-20160315-orig/src/livestreamer_cli/main.py 2016-03-15 06:28:45.000000000 +0200
+++ livestreamer-20160315/src/livestreamer_cli/main.py  2016-09-15 20:47:15.000000000 +0300
@@ -15,6 +15,7 @@
                           NoPluginError)
 from livestreamer.cache import Cache
 from livestreamer.stream import StreamProcess
+from livestreamer.plugins.twitch import TWITCH_CLIENT_ID

 from .argparser import parser
 from .compat import stdout, is_win32
@@ -531,7 +532,7 @@
     """Opens a web browser to allow the user to grant Livestreamer
        access to their Twitch account."""

-    client_id = "ewvlchtxgqq88ru9gmfp1gmyt6h2b93"
+    client_id = TWITCH_CLIENT_ID
     redirect_uri = "http://livestreamer.tanuki.se/en/develop/twitch_oauth.html"
     url = ("https://api.twitch.tv/kraken/oauth2/authorize/"
            "?response_type=token&client_id={0}&redirect_uri="
4jb commented 8 years ago

Those having issues with livestreamerrc, this is the exact line I added to make it work again:

http-header=Client-ID=ewvlchtxgqq88ru9gmfp1gmyt6h2b93

Personally, I prefer to not show up in the viewer list when using LiveStreamer, but that's just me.

CowCowCowCow commented 8 years ago

@4jb Thanks, for some reason it's working fine on windows but not linux.. probably my fault anyway.

javiercantero commented 8 years ago

@LoneFox78 Maybe you don't know python but your patch is correct. :) Could you please fork the livestreamer repo and create a branch with your changes? (a Pull Request will be even better). I want to pull your patch to my repo while keeping your authorship (because there are other changes that I want to apply upon it).

gravyboat commented 8 years ago

For those of you who just want an example using the client ID:

livestreamer --http-header Client-ID=jzkbprff40iqj646a697cyrvl0zt2m6 twitch.tv/streamer best

LoneFox78 commented 8 years ago

@javiercantero Done. For some reason it does not allow me to select your repository for the pull request, so I made it for this (chrippa's) repo instead. At least this way it is in the same place as all other accumulated fixes...

javiercantero commented 8 years ago

@LoneFox78 Perfect. From there, chrippa can merge it into upstream and also the rest of us can get the patch. Thank you.

gravyboat commented 8 years ago

@javiercantero, @chrippa no longer maintains this repo in any way, he hasn't merged a PR in over 6 months.

RainOne commented 8 years ago

@gravyboat Oh no, really? Where is the to-go version of livestreamer then? (did anybody fork and is maintaining it or this is still the best version?)

gravyboat commented 8 years ago

@RainOne It was just forked today over here: https://github.com/streamlink/streamlink you can see more regarding that discussion here: https://github.com/chrippa/livestreamer/issues/1427

javiercantero commented 8 years ago

@gravyboat The last time @chrippa merged patches also happened after a 5 months period without activity, so IMHO it's too soon to declare the project unmaintained. But it's true that it's not looking good.

gravyboat commented 8 years ago

@javiercantero As I said in another thread I contacted him in every way possible I could find, and even offered to pay him to merge in some of the more essential PRs to keep things going and he never responded. He is still active on GitHub.

nxtreaming commented 8 years ago

It seems that this good project has been dead. I will study the code firstly.

vadosnaprimer commented 8 years ago

What would be the correct ID anyway, ewvlchtxgqq88ru9gmfp1gmyt6h2b93 or jzkbprff40iqj646a697cyrvl0zt2m6?

lewisje commented 8 years ago

This works for me, in livestreamerrc:

http-header=Client-ID=jzkbprff40iqj646a697cyrvl0zt2m6

This is the variant for command-line usage:

livestreamer --http-header Client-ID=jzkbprff40iqj646a697cyrvl0zt2m6

One of these is necessary if, like me, you got a localized display name and found that Livestreamer can't deal with non-ASCII display names.

javiercantero commented 8 years ago

@vadosnaprimer One is the livestreamer own ID, another is the Twitch client ID. Both should work.

wildgoosespeeder commented 8 years ago

Boy, am I glad there is a work-around without requiring a livestreamer update! The required pieces were already there.

"livestreamer --twitch-oauth-authenticate"

naimbouallagui commented 7 years ago

i have the same problem now !!

didn’t get the access to this link to get the data (TwitchTV project) https://api.twitch.tv/kraken/users/freecodecamp/follows/ : and this is the problem: GET https://api.twitch.tv/kraken/users/freecodecamp/follows/ 404 () can any one help me !! Thanks…

lewisje commented 7 years ago

That isn't relevant to this issue, but I'll help out anyway; the API endpoints have changed: https://dev.twitch.tv/docs/api/reference#get-users

First you need a valid OAuth token or Client ID: https://dev.twitch.tv/docs/authentication

Next, use this URL, appending the token or client ID parameter, to find the User ID for freecodecamp: https://api.twitch.tv/helix/users?login=freecodecamp

Finally, this is how you get the follows: https://dev.twitch.tv/docs/api/reference#get-users-follows