Repository: streamlink/streamlink

Issue:
YuppTV - Invalid captcha token
<!--
Thanks for reporting a plugin issue!
USE THE TEMPLATE. Otherwise your plugin issue may be rejected.

First, see the contribution guidelines:
https://github.com/streamlink/streamlink/blob/master/CONTRIBUTING.md#contributing-to-streamlink

Also check the list of open and closed plugin issues:
https://github.com/streamlink/streamlink/issues?q=is%3Aissue+label%3A%22plugin+issue%22

Please see the text preview to avoid unnecessary formatting errors.
-->


## Plugin Issue

<!-- Replace [ ] with [x] in order to check the box -->
- [x ] This is a plugin issue and I have read the contribution guidelines.

<!-- Explain the plugin issue as thoroughly as you can. -->

YuppTV seems to have added some sort of login captcha (looks to be Google's recaptcha) which is preventing logging into the website and getting access to paid/premium streams. Free streams which do not require login still work.
I am willing to provide an account temporarily for anyone that might be interested in fixing this. They will need a UK IP during testing.

### Reproduction steps / Explicit stream URLs to test

<!-- How can we reproduce this? Please note the exact steps below using the list format supplied. If you need more steps please add them. -->

1. Use relevant Streamlink parameters for premium stream requiring login.
streamlink --yupptv-email=myemail@gmail.com --yupptv-password=password123 --http-no-ssl-verify https://www.yupptv.com/channels/star-plus-uk/live

2. Failed Login and no stream output.


### Log output

<!--
TEXT LOG OUTPUT IS REQUIRED for a plugin issue!
Use the `--loglevel debug` parameter and avoid using parameters which suppress log output.
https://streamlink.github.io/cli.html#cmdoption-l

Make sure to **remove usernames and passwords**
You can copy the output to https://gist.github.com/ or paste it below.
-->

```
**Premium stream requiring login** (Does not work)

C:\Users\*****>streamlink --yupptv-email=myemail@gmail.com --yupptv-password=password123  --http-no-ssl-verify https://www.yupptv.com/channels/star-plus-uk/live --loglevel debug
[cli][debug] OS:         Windows 10
[cli][debug] Python:     3.6.6
[cli][debug] Streamlink: 1.5.0
[cli][debug] Requests(2.24.0), Socks(1.7.1), Websocket(0.57.0)
[cli][info] Found matching plugin yupptv for URL https://www.yupptv.com/channels/star-plus-uk/live
[cli][debug] Plugin specific arguments:
[cli][debug]  --yupptv-email=myemail@gmail.com (email)
[cli][debug]  --yupptv-password=*****  (password)
[plugin.yupptv][error] Failed to login: Invalid  captcha token (code: 403)
[plugin.yupptv][error] This stream requires you to login
error: No playable streams found on this URL: https://www.yupptv.com/channels/star-plus-uk/live




**Free stream not requiring login**  (Does work)

C:\Users\*****>streamlink --http-no-ssl-verify https://www.yupptv.com/channels/aajtak/live best --loglevel debug
[cli][debug] OS:         Windows 10
[cli][debug] Python:     3.6.6
[cli][debug] Streamlink: 1.5.0
[cli][debug] Requests(2.24.0), Socks(1.7.1), Websocket(0.57.0)
[cli][info] Found matching plugin yupptv for URL https://www.yupptv.com/channels/aajtak/live
[utils.l10n][debug] Language code: en_GB
[cli][info] Available streams: 216p (worst), 270p, 288p, 396p, 406p (best)
[cli][info] Opening stream: 406p (hls)
[stream.hls][debug] Reloading playlist
[stream.hls][debug] First Sequence: 9065; Last Sequence: 9094
[stream.hls][debug] Start offset: 0; Duration: None; Start Sequence: 9092; End Sequence: None
[stream.hls][debug] Adding segment 9092 to queue
[cli][debug] Pre-buffering 8192 bytes
[stream.hls][debug] Adding segment 9093 to queue
[stream.hls][debug] Adding segment 9094 to queue
[cli][info] Starting player: "C:\Program Files\VideoLAN\VLC\vlc.exe"
[stream.hls][debug] Download of segment 9092 complete
[cli.output][debug] Opening subprocess: "C:\Program Files\VideoLAN\VLC\vlc.exe" --input-title-format https://www.yupptv.com/channels/aajtak/live -
[stream.hls][debug] Download of segment 9093 complete
[cli][debug] Writing stream to output
...

```


### Additional comments, screenshots, etc.



[Love Streamlink? Please consider supporting our collective. Thanks!](https://opencollective.com/streamlink/donate)



Discussion:
It *might* be possible to sidestep this by providing the right login cookie to streamlink and passing it via the ```--http-cookie``` parameter on the command line.

The first thing you would need to do is identify the cookie.  In Firefox (after logging in to YuppTV in the browser), you can open the debugger with F12, then click the Storage tab.  You should look for cookie names that have words like ```sess```, ```session```, ```user```, ```token```, ```auth``` in them under ```yupptv.com``` in the left window pane.

You can click on each cookie to get details in a right window pane.  Let's say you find a likely candidate called ```authtoken``` with a value of ```randomstring```.  You could then try this:

```streamlink --http-cookie authtoken=randomstring --http-no-ssl-verify https://www.yupptv.com/channels/star-plus-uk/live --loglevel debug```

It's likely that if this works, the token will eventually expire, in which case you will have to renew it by logging in again via the browser and replacing the old ```randomstring``` value with the new one.
Additional tip: if you open the debugger before logging in, then log in and then log out again, while keeping the debugger open, the cookies which are modified will be highlighted briefly in the cookie list window pane, new cookies will appear and deleted cookies will disappear.
Unfortunately, whatever tokens I used I got the same result. I don't know if this is caused by the stream plugin refusing to continue without login parameters on a premium stream or because this method simply wont work.

C:\Users\*****>streamlink --http-cookie 'abc=123' --http-no-ssl-verify https://www.yupptv.com/channels/star-plus-uk/live best --loglevel debug
[cli][debug] OS:         Windows 10
[cli][debug] Python:     3.6.6
[cli][debug] Streamlink: 1.5.0
[cli][debug] Requests(2.24.0), Socks(1.7.1), Websocket(0.57.0)
[cli][info] Found matching plugin yupptv for URL https://www.yupptv.com/channels/star-plus-uk/live
[plugin.yupptv][error] This stream requires you to login
error: No playable streams found on this URL: https://www.yupptv.com/channels/star-plus-uk/live


> I don't know if this is caused by the stream plugin refusing to continue without login parameters on a premium stream

The login will only be done if plugin parameters for the email and password are set:
https://github.com/streamlink/streamlink/blob/1.5.0/src/streamlink/plugins/yupptv.py#L62-L67

And the login itself only fetches cookies from the login request, which are then stored on the HTTP session for the next requests:
https://github.com/streamlink/streamlink/blob/1.5.0/src/streamlink/plugins/yupptv.py#L40-L57

This means that you'll have to figure out the cookies yourself or set everything your web browser has set via the [`--http-cookie`](https://streamlink.github.io/cli.html#cmdoption-http-cookie) or [`--http-header`](https://streamlink.github.io/cli.html#cmdoption-http-header) parameters. Note that the plugin performs its login up to three times, until all other devices are logged out, as reported by the site.

Regarding the plugin's login parameters themselves, they are now useless due to the new captcha codes added by the streaming site and thus need to be removed, as there is no way around that for Streamlink.

If someone figures out which exact cookies are needed, a new plugin parameter could be added, similar to #2840.
I've not had any luck tinkering so If anyone is willing to take a look,  I can provide a account.
@mytee12, I have some work in progress on this.  I'll ping you on here when I have something ready for testing.
Many thanks to @bastimeyer for pointing me to the pixiv plugin.  The code was very useful.  I mostly just copied and pasted the cookie code with a few modifications, as necessary.

@mytee12, I now have an updated yupptv plugin ready for testing.  You can get it from:

https://github.com/mkbloke/streamlink/blob/yupptv-site-change-2020-08/src/streamlink/plugins/yupptv.py

On that page, just select 'Raw', then 'File/Save Page As' in your browser.  You can backup the old plugin if you like, although as it doesn't work, there's probably not much point, then copy or move the newly downloaded plugin into your local streamlink plugins directory.

If you could help with testing by following the test regime I'm outlining below, it would very much be appreciated, thanks.

There's no need to report any output if the plugin works as expected, but debug output for tests that don't perform as expected would be very useful.

[Updated to add: include the ```--http-no-ssl-verify``` option to the testing regime command lines below if it's necessary for your system]

Firstly, let's try without authentication:

```streamlink -l debug https://www.yupptv.com/channels/aajtak/live best```
Should play without any errors.

```streamlink -l debug https://www.yupptv.com/channels/star-plus-uk/live best```
Should show:
```
[plugin.yupptv][error] This stream requires you to login
error: No playable streams found on this URL: https://www.yupptv.com/channels/star-plus-uk/live
```

There are two cookies required for login to YuppTV, these are ```BoxId``` and ```YuppflixToken```.  As detailed in my post above, you can extract the required values for each of these via the browser.  Here are examples of what they should look like:

BoxId ```519a4cdaedee4d53```
YuppflixToken ```YT-8b5fae6b-d794-4beb-431c-36012f3b198f```

When you have the cookie values for a given session, you must leave it logged in within the browser, i.e. do not click 'Logout` on the YuppTV website, otherwise you'll invalidate the credendtials.  I'm going to use my example cookie values below, but you should of course replace them with the ones you have obtained from your session.

This updated plugin now caches your cookie values which are used to access YuppTV.  That means you only need to specify them once on the command line, unless you need to update them (more on that below).

```streamlink -l debug --yupptv-boxid 519a4cdaedee4d53 --yupptv-yuppflixtoken YT-8b5fae6b-d794-4beb-431c-36012f3b198f https://www.yupptv.com/channels/aajtak/live best```
Should play without any errors.

Now that the credentials are cached and if your YuppTV subscription package allows you to play it (I'm assuming from your original post that it should):

```streamlink -l debug https://www.yupptv.com/channels/star-plus-uk/live best```
Should play using the cached credentials without any errors.

I don't know what subscription you have, but if you can find any content that requires further subscription, then:

```streamlink -l debug https://www.yupptv.com/a-link-to-content-requiring-further-subscription best```
Should in theory show:
```
[plugin.yupptv][debug] Attempting to authenticate using cached cookies
[plugin.yupptv][error] This stream requires a subscription
error: No playable streams found on this URL: https://www.yupptv.com/a-link-to-content-requiring-further-subscription
```

If, when using this updated plugin, you encounter output like:
```
[plugin.yupptv][debug] Attempting to authenticate using cached cookies
[plugin.yupptv][error] This device requires renewed credentials to log in
error: No playable streams found on this URL: https://www.yupptv.com/channels/aajtak/live
```
it means that the cached credentials are no longer considered valid by the YuppTV website.  This could be because:
- You have been using the credentials for a long time and the YuppTV website now considers them expired
- You have logged into YuppTV via another device and forced the logout of this session (device)

In that case, you will need to renew the credentials by logging in again with a browser, extracting the new BoxId and YuppflixToken values, then start streamlink with the parameters shown below to update the cached credentials:

```streamlink --yupptv-purge-credentials --yupptv-boxid ```my_new_boxid_value``` --yupptv-yuppflixtoken ```my_new_yuppflixtoken_value``` https://www.yupptv.com/channels/aajtak/live best```

If you just want to remove the cached credentials for the plugin, you can just use:

```streamlink --yupptv-purge-credentials https://www.yupptv.com/channels/aajtak/live```

You can use any YuppTV URL that is recognised by the plugin in the above examples when using the credentials options.  If you do not wish to play any content after using the credentials options, just use the URL and do not specify the second command line argument, i.e. the stream quality, as shown in the ```--yupptv-purge-credentials``` example immediately above.

Finally, here's a last note on this updated plugin:

The previous plugin featured the ability to logout other devices, but this plugin can no longer do that.  It's a catch-22 situation.  If you have logged in via another device and forced logout of other devices, you are invalidating the credentials cached by streamlink for YuppTV access.  When you log in via a browser, you first authenticate via the login form, but that involves Google reCAPTCHA, which cannot be done by a streamlink plugin, therefore the plugin cannot authenticate to get to the option of logging out other devices.  This means that if you log into YuppTV on another device and force the logout of other devices, you will see:
```
[plugin.yupptv][debug] Attempting to authenticate using cached cookies
[plugin.yupptv][error] This device requires renewed credentials to log in
error: No playable streams found on this URL: https://www.yupptv.com/channels/aajtak/live
```
when you next attempt to use the streamlink plugin and you will have to go through the process of specifying renewed cookie values as detailed above.
Highly appreciate your efforts.

1. Free stream without any cached credentials. Works.

```
C:\Users\*>streamlink -l debug --http-no-ssl-verify https://www.yupptv.com/channels/aajtak/live best
[session][debug] Plugin yupptv is being overridden by C:\Users\*\AppData\Roaming\streamlink\plugins\yupptv.py
[cli][debug] OS:         Windows 10
[cli][debug] Python:     3.6.6
[cli][debug] Streamlink: 1.5.0
[cli][debug] Requests(2.24.0), Socks(1.7.1), Websocket(0.57.0)
[cli][info] Found matching plugin yupptv for URL https://www.yupptv.com/channels/aajtak/live
[utils.l10n][debug] Language code: en_GB
[cli][info] Available streams: 216p (worst), 270p, 288p, 396p, 406p (best)
[cli][info] Opening stream: 406p (hls)
[stream.hls][debug] Reloading playlist
[stream.hls][debug] First Sequence: 9282; Last Sequence: 9311
...
```

Unfortunately, I am not able to get past the step of using a free stream with the boxid and yuppflixtoken parameters. Here are my steps:

1. Clear credentials.

```
C:\Users\*>streamlink -l debug --http-no-ssl-verify --yupptv-purge-credentials https://www.yupptv.com/channels/aajtak/live
[session][debug] Plugin yupptv is being overridden by C:\Users\*\AppData\Roaming\streamlink\plugins\yupptv.py
[cli][debug] OS:         Windows 10
[cli][debug] Python:     3.6.6
[cli][debug] Streamlink: 1.5.0
[cli][debug] Requests(2.24.0), Socks(1.7.1), Websocket(0.57.0)
[cli][info] Found matching plugin yupptv for URL https://www.yupptv.com/channels/aajtak/live
[cli][debug] Plugin specific arguments:
[cli][debug]  --yupptv-purge-credentials=True (purge_credentials)
[plugin.yupptv][info] All credentials were successfully removed
[utils.l10n][debug] Language code: en_GB
Available streams: 216p (worst), 270p, 288p, 396p, 406p (best)
```

2. Retrieve new boxid and yuppflixtoken from website. Not logging out.

3. Use new tokens with plugin.

```
C:\Users\*>streamlink -l debug --http-no-ssl-verify --yupptv-boxid '****' --yupptv-yuppflixtoken 'YT-****' https://www.yupptv.com/channels/aajtak/live best
[session][debug] Plugin yupptv is being overridden by C:\Users\*\AppData\Roaming\streamlink\plugins\yupptv.py
[cli][debug] OS:         Windows 10
[cli][debug] Python:     3.6.6
[cli][debug] Streamlink: 1.5.0
[cli][debug] Requests(2.24.0), Socks(1.7.1), Websocket(0.57.0)
[cli][info] Found matching plugin yupptv for URL https://www.yupptv.com/channels/aajtak/live
[cli][debug] Plugin specific arguments:
[cli][debug]  --yupptv-boxid=******** (boxid)
[cli][debug]  --yupptv-yuppflixtoken=******** (yuppflixtoken)
[plugin.yupptv][debug] Saved cookies: BoxId, YuppflixToken
[plugin.yupptv][info] Successfully set BoxId and YuppflixToken
[plugin.yupptv][error] This device requires renewed credentials to log in
error: No playable streams found on this URL: https://www.yupptv.com/channels/aajtak/live
```

And of course, I get the same result with a premium stream.  

I tried many times with new fresh credentials. If I tested the boxid/yuppflixtoken and manually set them in a clean Firefox session, they were active and allowed me to login bypassing the captcha.
Hi @mytee12, many thanks for the feedback.

I have pushed a small change to the plugin, which can again be downloaded from:

https://github.com/mkbloke/streamlink/blob/yupptv-site-change-2020-08/src/streamlink/plugins/yupptv.py

This is a bit of a shot in the dark and based purely on a hunch, but this small modification calls the signin URL, which I notice sets various cookies in its response.  It's *possible* some of these could be relevant for somebody with an account that has subscribed packages on YuppTV.

It might be best to start with ```--yupptv-purge-credentials```, then follow the test regime as before.  Thanks.

Same result with the new changes sadly.

```
C:\Users\*>streamlink --http-no-ssl-verify -l debug --yupptv-boxid '*' --yupptv-yuppflixtoken '*' https://www.yupptv.com/channels/aajtak/live best
[session][debug] Plugin yupptv is being overridden by C:\Users\*\AppData\Roaming\streamlink\plugins\yupptv.py
[cli][debug] OS:         Windows 10
[cli][debug] Python:     3.6.6
[cli][debug] Streamlink: 1.5.0
[cli][debug] Requests(2.24.0), Socks(1.7.1), Websocket(0.57.0)
[cli][info] Found matching plugin yupptv for URL https://www.yupptv.com/channels/aajtak/live
[cli][debug] Plugin specific arguments:
[cli][debug]  --yupptv-boxid=******** (boxid)
[cli][debug]  --yupptv-yuppflixtoken=******** (yuppflixtoken)
[plugin.yupptv][debug] Saved cookies: BoxId, YuppflixToken
[plugin.yupptv][info] Successfully set BoxId and YuppflixToken
[plugin.yupptv][error] This device requires renewed credentials to log in
error: No playable streams found on this URL: https://www.yupptv.com/channels/aajtak/live
```

@mytee12, I think I've got it - I'm an idiot!  I managed to reproduce what you're seeing by booting into Windows 10 and testing it there...

I've reverted the last commit to the plugin, so if you can download it again from:

https://github.com/mkbloke/streamlink/blob/yupptv-site-change-2020-08/src/streamlink/plugins/yupptv.py

and go through the testing regime again, it would be much appreciated.  This time, you'll note that none of the command lines shown place single quotes around the values specified for the cookie parameters.  It turns out, that under Windows, the single quotes are saved as part of the cookie value - doh!  I will remember that for the future!

Cheers.

Updated to add: maybe start the testing again with ```--yupptv-purge-credentials```, then add the credentials back during the test regime, but without the single quotes (obviously) this time!
I can confirm that we have lift off! Both free and premium stream are working. Thank you very much @mkbloke 
I will update on how long the tokens take to expire for anyone who is interested in knowing.

To clarify for any others, your commands should be like the following, replacing the random strings `342a4cqwedey4d73` and `YT-7h2fae6b-u643-5ctc-483f-11856f3b155p` with the appropriate tokens and the stream link of your choosing e.g.

`streamlink --http-no-ssl-verify -l debug --yupptv-boxid 342a4cqwedey4d73 --yupptv-yuppflixtoken YT-7h2fae6b-u643-5ctc-483f-11856f3b155p https://www.yupptv.com/channels/star-plus-uk/live best`

To get the tokens... use Firefox and log into your YuppTV account, press F12 on your keyboard and go to the _Storage_ tab at the top. You should see the _cookies_ section and go to yupptv.com. Copy the _Value_ of _BoxId_ and _YuppflixToken_ and use them in your streamlink parameters above. Make sure you do not click the logout button on YuppTV website, instead just close it.
That's excellent news.  Thanks for the testing, @mytee12.

Just to reiterate, it should only be necessary to use the ```--yupptv-boxid``` and ```--yupptv-yuppflixtoken``` options once while the cookie values remain valid.  It should be possible to simply use (with ```--http-no-ssl-verify``` if necessary on your system):

```streamlink https://www.yupptv.com/channels/star-plus-uk/live best```

for as long as you have valid credentials cached.  I've updated https://github.com/streamlink/streamlink/issues/3094#issuecomment-672554453 appropriately within this thread, so the info on renewing with: ```--yupptv-purge-credentials```, ```--yupptv-boxid my_new_boxid_value``` and ```--yupptv-yuppflixtoken my_new_yuppflixtoken_value``` also applies, as does using ```--yupptv-purge-credentials``` on its own to clear the cached credentials.
How long do login and stream cookies last? Last time I tried got the account banned but it may be because runit was executing too many times? What's the best way to set up a stream?
> How long do login and stream cookies last?

Try it and see, or wait and see if mytee12 gets back with that information.

> What's the best way to set up a stream?

I'm not quite sure what you mean.  With reference to the instructions above, having stored the credentials, you just run streamlink with the URL and stream as command line arguments.  You can find the available streams by running streamlink with just the URL argument.
~~I've looked at the ```expires``` values for the cookies I have and it seems to indicate that the cookies are valid for 7 days.~~
> 
> 
> How long do login and stream cookies last? 


> 
> 
> I've looked at the `expires` values for the cookies I have and it seems to indicate that the cookies are valid for 7 days.

I had to renew my tokens today to check for sure but I used them for 8 days. Checking `BoxId` and `YuppflixToken` in Chrome shows an expiration of 180 days : `2021-02-17T14:20:16.313Z`




> 
> 
>  Last time I tried got the account banned but it may be because runit was executing too many times? 

I've been using this addon for over 6 months via [LiveProxy](https://streamlink.github.io/thirdparty.html) 


Thanks for coming back on the cookie expiry.

> I've looked at the `expires` values for the cookies I have and it seems to indicate that the cookies are valid for 7 days.

I've retracted that in the post above.  I was looking at the wrong thing, so it's incorrect.
> > How long do login and stream cookies last?
> 
> > I've looked at the `expires` values for the cookies I have and it seems to indicate that the cookies are valid for 7 days.
> 
> I had to renew my tokens today to check for sure but I used them for 8 days. Checking `BoxId` and `YuppflixToken` in Chrome shows an expiration of 180 days : `2021-02-17T14:20:16.313Z`
> 
> > Last time I tried got the account banned but it may be because runit was executing too many times?
> 
> I've been using this addon for over 6 months via [LiveProxy](https://streamlink.github.io/thirdparty.html)

Thank you. I'll try that. What exactly is the purpose of LiveProxy in this case?
> What exactly is the purpose of LiveProxy in this case?

LiveProxy allows me to essentially have a Streamlink server running in my home network and use Streamlink on devices where installing Streamlink might not be possible or elegant. I currently use an [android](https://www.reddit.com/r/Streamlink/comments/cfno18/guide_streamlink_on_android_termux_vlc/) box I had laying around as a Streamlink server.

It also lets me create a easy to use M3U playlist with Streamlink/Liveproxy urls consisting of YuppTV channels. In my case I use the M3U playlist with an IPTV player app on a Firestick, a much more user friendly experience.
Thanks guys. Really appreciate your hard work!
Folks, do you by any chance experience a similar issue? 1 channel in particular Sony UK HD is throwing 404(i removed token details) error but after I restart the session it starts working

`2020-09-14_21:27:23.34232 [stream.hls][debug] Download of segment 50405 complete
2020-09-14_21:27:29.14064 [stream.hls][debug] Reloading playlist
2020-09-14_21:27:32.23414 [stream.hls][debug] Reloading playlist
2020-09-14_21:27:34.74914 [stream.hls][warning] Failed to reload playlist: Unable to open URL: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8? (404 Client Error: Not Found for url: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8?)
2020-09-14_21:27:37.75189 [stream.hls][debug] Reloading playlist
2020-09-14_21:27:40.12936 [stream.hls][warning] Failed to reload playlist: Unable to open URL: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8? (404 Client Error: Not Found for url: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8?)
2020-09-14_21:27:43.13188 [stream.hls][debug] Reloading playlist
2020-09-14_21:27:45.70842 [stream.hls][warning] Failed to reload playlist: Unable to open URL: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8? (404 Client Error: Not Found for url: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8?)
2020-09-14_21:27:48.71147 [stream.hls][debug] Reloading playlist
2020-09-14_21:27:51.09119 [stream.hls][warning] Failed to reload playlist: Unable to open URL: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8? (404 Client Error: Not Found for url: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8?)
2020-09-14_21:27:54.09427 [stream.hls][debug] Reloading playlist
2020-09-14_21:27:56.69180 [stream.hls][warning] Failed to reload playlist: Unable to open URL: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8? (404 Client Error: Not Found for url: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8?)
2020-09-14_21:27:59.69504 [stream.hls][debug] Reloading playlist
2020-09-14_21:28:02.07630 [stream.hls][warning] Failed to reload playlist: Unable to open URL: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8? (404 Client Error: Not Found for url: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8?)
2020-09-14_21:28:04.02787 [stream.segmented][debug] Closing worker thread
2020-09-14_21:28:04.02789 [stream.segmented][debug] Closing writer thread
2020-09-14_21:28:04.02790 [cli][info] Stream ended
2020-09-14_21:28:04.02790 Interrupted! Exiting...
2020-09-14_21:28:04.02790 [cli][info] Closing currently open stream...
2020-09-14_21:28:04.02791 Failed to load plugin ustvnow:
2020-09-14_21:28:04.02791   File "/usr/lib/python3.7/imp.py", line 234, in load_module
2020-09-14_21:28:04.02792     return load_source(name, filename, file)
2020-09-14_21:28:04.02792   File "/usr/lib/python3.7/imp.py", line 171, in load_source
2020-09-14_21:28:04.02792     module = _load(spec)
2020-09-14_21:28:04.02793   File "<frozen importlib._bootstrap>", line 696, in _load
2020-09-14_21:28:04.02793   File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
2020-09-14_21:28:04.02793   File "<frozen importlib._bootstrap_external>", line 728, in exec_module
2020-09-14_21:28:04.02794   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2020-09-14_21:28:04.02794   File "/usr/local/lib/python3.7/dist-packages/streamlink-1.3.1+182.gb3132d7-py3.7.egg/streamlink/plugins/ustvnow.py", line 12, in <module>
2020-09-14_21:28:04.02794     from Crypto.Util.Padding import pad, unpad
2020-09-14_21:28:04.02795 ModuleNotFoundError: No module named 'Crypto.Util.Padding'
2020-09-14_21:28:04.02795 
2020-09-14_21:30:02.95929 [plugin.yupptv][debug] Restored cookies: BoxId, YuppflixToken
2020-09-14_21:30:02.96410 [cli][info] streamlink is running as root! Be careful!
2020-09-14_21:30:02.96517 [cli][debug] OS:         Linux-4.19.0-10-amd64-x86_64-with-debian-10.5
2020-09-14_21:30:02.96530 [cli][debug] Python:     3.7.3
2020-09-14_21:30:02.96540 [cli][debug] Streamlink: 1.3.1+182.gb3132d7
2020-09-14_21:30:02.96550 [cli][debug] Requests(2.21.0), Socks(1.6.7), Websocket(0.53.0)
2020-09-14_21:30:02.96574 [cli][info] Found matching plugin yupptv for URL https://www.yupptv.com/channels/sony-tv-hd/live
2020-09-14_21:30:02.96585 [cli][debug] Plugin specific arguments:
2020-09-14_21:30:02.96595 [cli][debug]  --yupptv-boxid=******** (boxid)
2020-09-14_21:30:02.96605 [cli][debug]  --yupptv-yuppflixtoken=******** (yuppflixtoken)
2020-09-14_21:30:02.96621 [plugin.yupptv][debug] Attempting to authenticate using cached cookies
2020-09-14_21:30:04.27101 [utils.l10n][debug] Language code: en_US
2020-09-14_21:30:04.74955 [cli][info] Available streams: 270p (worst), 360p, 540p, 720p (best)
2020-09-14_21:30:04.74990 [cli][info] Starting server, access with one of:
2020-09-14_21:30:04.82587 [cli][info]  http://127.0.0.1:11002/
2020-09-14_21:30:10.81929 [cli][info] Got HTTP request from Streamer 20.09
2020-09-14_21:30:10.81948 [cli][info] Opening stream: 720p (hls)
2020-09-14_21:30:10.82009 [stream.hls][debug] Reloading playlist
2020-09-14_21:30:13.33534 [cli][error] Could not open stream: Unable to open URL: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8? (404 Client Error: Not Found for url: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8?)
2020-09-14_21:30:13.33575 [plugin.yupptv][debug] Attempting to authenticate using cached cookies
2020-09-14_21:30:13.87706 [utils.l10n][debug] Language code: en_US
2020-09-14_21:30:13.95485 [cli][info] Opening stream: 720p (hls)
2020-09-14_21:30:13.95526 [stream.hls][debug] Reloading playlist
2020-09-14_21:30:16.33582 [cli][error] Could not open stream: Unable to open URL: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8? (404 Client Error: Not Found for url: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8?)
2020-09-14_21:30:16.33613 [plugin.yupptv][debug] Attempting to authenticate using cached cookies
2020-09-14_21:30:17.03601 [utils.l10n][debug] Language code: en_US
2020-09-14_21:30:17.11543 [cli][info] Opening stream: 720p (hls)
2020-09-14_21:30:17.11579 [stream.hls][debug] Reloading playlist
2020-09-14_21:30:19.49311 [cli][error] Could not open stream: Unable to open URL: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8? (404 Client Error: Not Found for url: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8?)
2020-09-14_21:30:19.49333 [plugin.yupptv][debug] Attempting to authenticate using cached cookies
2020-09-14_21:30:20.03681 [utils.l10n][debug] Language code: en_US
2020-09-14_21:30:20.11409 [cli][info] Opening stream: 720p (hls)
2020-09-14_21:30:20.11448 [stream.hls][debug] Reloading playlist
2020-09-14_21:30:22.59907 [cli][error] Could not open stream: Unable to open URL: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8? (404 Client Error: Not Found for url: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8?)
2020-09-14_21:30:22.59929 [plugin.yupptv][debug] Attempting to authenticate using cached cookies
2020-09-14_21:30:23.15075 [utils.l10n][debug] Language code: en_US
2020-09-14_21:30:23.22917 [cli][info] Opening stream: 720p (hls)
2020-09-14_21:30:23.22976 [stream.hls][debug] Reloading playlist
2020-09-14_21:30:25.61056 [cli][error] Could not open stream: Unable to open URL: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8? (404 Client Error: Not Found for url: https://yuppmsleuvia1.akamaized.net/hls/live/2017574/sonyukhdhttps/sonyukhdhttps/sonyukhd_2500/chunklist.m3u8?)
2020-09-14_21:30:25.61074 [plugin.yupptv][debug] Attempting to authenticate using cached cookies
2020-09-14_21:30:26.16795 [utils.l10n][debug] Language code: en_US
2020-09-14_21:30:26.24559 [cli][info] Opening stream: 720p (hls)
2020-09-14_21:30:26.24606 [stream.hls][debug] Reloading playlist
`
@limiteddi, can you reformat the above to make it a little more readable, please?  I think what you have done (where b=backtick) is specified bbb[content]bbb.  If you format it as:

bbb
[content]
bbb

it should be easier to read.

Can you also specify the full command you are using to launch streamlink.

When does this happen - after a short time or a long time?  How long?

Does the live stream play in the browser on yupptv.com OK for the same period of time?

I don't have a subscription, so it won't be easy to try and work out why this is happening or if it can be mitigated in streamlink, as a 404 error suggests a remote issue.
@mkbloke 

Took me a while to figure out what was happening, but it seems that after 7 days the cache in the file `plugin-cache.json` is automatically purged. However, If I re-set the SAME credentials again they will continue working... I have done this 3 times with the same tokens and the only change is the `expires` in the `plugin-cache.json file` . So it is possibly the expiry date being set in the cache file incorrectly causing the credentials to be purged prematurely?


Prior to trying a stream - plugin-cache.json file:
```
"expires": 1600559413.4241705
"expires": 1600559413.455421
```

Trying to play a stream and YuppTV credentials are purged automatically from plugin-cache.json:
`{}`
```
[plugin.yupptv][error] This stream requires you to login
error: No playable streams found on this URL: https://www.yupptv.com/channels/star-plus-uk/live
```

After setting new credentials, new expiry date with same credentials:
```
"expires": 1601164607.7820444
"expires": 1601164607.8171265
```

Resolving patch:
diff --git a/src/streamlink/plugins/yupptv.py b/src/streamlink/plugins/yupptv.py
--- a/src/streamlink/plugins/yupptv.py
+++ b/src/streamlink/plugins/yupptv.py
@@ -1,7 +1,8 @@
+import argparse
 import logging
 import re
+import time
 
-from streamlink import PluginError
 from streamlink.plugin import Plugin, PluginArguments, PluginArgument
 from streamlink.plugin.api import useragents
 from streamlink.stream import HLSStream
@@ -11,62 +12,94 @@
 
 
 class YuppTV(Plugin):
-    _url_re = re.compile(r"""https?://(?:www\.)?yupptv\.com""", re.VERBOSE)
+    _url_re = re.compile(r'https?://(?:www\.)?yupptv\.com')
     _m3u8_re = re.compile(r'''['"](http.+\.m3u8.*?)['"]''')
-    _login_url = "https://www.yupptv.com/auth/validateSignin"
-    _box_logout = "https://www.yupptv.com/auth/confirmLogout"
-    _signin_url = "https://www.yupptv.com/signin/"
-    _account_url = "https://www.yupptv.com/account/myaccount.aspx"
+    _cookie_expiry = 3600 * 24 * 365
 
     arguments = PluginArguments(
+        PluginArgument("email", help=argparse.SUPPRESS),
+        PluginArgument("password", help=argparse.SUPPRESS),
         PluginArgument(
-            "email",
-            requires=["password"],
-            metavar="EMAIL",
-            help="Your YuppTV account email"
-        ),
+            "boxid",
+            requires=["yuppflixtoken"],
+            sensitive=True,
+            metavar="BOXID",
+            help="""
+        The yupptv.com boxid that's used in the BoxId cookie.
+        Can be used instead of the username/password login process.
+        """),
         PluginArgument(
-            "password",
+            "yuppflixtoken",
             sensitive=True,
-            metavar="PASSWORD",
-            help="Your YuppTV account password."
-        )
+            metavar="YUPPFLIXTOKEN",
+            help="""
+        The yupptv.com yuppflixtoken that's used in the YuppflixToken cookie.
+        Can be used instead of the username/password login process.
+        """),
+        PluginArgument(
+            "purge-credentials",
+            action="store_true",
+            help="""
+        Purge cached YuppTV credentials to initiate a new session
+        and reauthenticate.
+        """),
     )
 
+    def __init__(self, url):
+        super(YuppTV, self).__init__(url)
+        self._authed = (self.session.http.cookies.get("BoxId")
+                        and self.session.http.cookies.get("YuppflixToken"))
+
     @classmethod
     def can_handle_url(cls, url):
         return cls._url_re.match(url) is not None
 
-    def login(self, username, password, depth=3):
-        if depth == 0:
-            log.error("Failed to login to YuppTV")
-            raise PluginError("cannot login")
+    def _login_using_box_id_and_yuppflix_token(self, box_id, yuppflix_token):
+        time_now = time.time()
 
-        res = self.session.http.post(
-            self._login_url,
-            data=dict(user=username, password=password, isMobile=0),
-            headers={"Referer": self._signin_url}
+        self.session.http.cookies.set(
+            'BoxId',
+            box_id,
+            domain='www.yupptv.com',
+            path='/',
+            expires=time_now + self._cookie_expiry,
+        )
+        self.session.http.cookies.set(
+            'YuppflixToken',
+            yuppflix_token,
+            domain='www.yupptv.com',
+            path='/',
+            expires=time_now + self._cookie_expiry,
         )
-        data = self.session.http.json(res)
-        resp = data['Response']
-        if resp["tempBoxid"]:
-            # log out on other device
-            log.info("Logging out on other device: {0}".format(resp["tempBoxid"]))
-            _ = self.session.http.get(self._box_logout, params=dict(boxId=resp["tempBoxid"]))
-            return self.login(username, password, depth - 1)
-        return resp['errorCode'], resp['statusmsg']
+
+        self.save_cookies()
+        log.info("Successfully set BoxId and YuppflixToken")
 
     def _get_streams(self):
         self.session.http.headers.update({"User-Agent": useragents.CHROME})
 
-        if self.get_option("email") and self.get_option("password"):
-            error_code, error_msg = self.login(self.get_option("email"), self.get_option("password"))
-            if error_code is None:
-                log.info("Logged in as {0}".format(self.get_option("email")))
-            else:
-                log.error("Failed to login: {1} (code: {0})".format(error_code, error_msg))
+        login_box_id = self.get_option("boxid")
+        login_yuppflix_token = self.get_option("yuppflixtoken")
+
+        if self.options.get("purge_credentials"):
+            self.clear_cookies()
+            self._authed = False
+            log.info("All credentials were successfully removed")
+
+        if self._authed:
+            log.debug("Attempting to authenticate using cached cookies")
+        elif not self._authed and login_box_id and login_yuppflix_token:
+            self._login_using_box_id_and_yuppflix_token(
+                login_box_id,
+                login_yuppflix_token,
+            )
+            self._authed = True
 
         page = self.session.http.get(self.url)
+        if self._authed and "btnsignup" in page.text:
+            log.error("This device requires renewed credentials to log in")
+            return
+
         match = self._m3u8_re.search(page.text)
         if match:
             stream_url = match.group(1)


Test patch:
diff --git a/tests/plugins/test_yupptv.py b/tests/plugins/test_yupptv.py
--- a/tests/plugins/test_yupptv.py
+++ b/tests/plugins/test_yupptv.py
@@ -3,13 +3,20 @@
 from streamlink.plugins.yupptv import YuppTV
 
 
-class TestPluginZattoo(unittest.TestCase):
+class TestPluginYuppTV(unittest.TestCase):
     def test_can_handle_url(self):
-        self.assertTrue(YuppTV.can_handle_url('https://www.yupptv.com/channels/etv-telugu/live'))
-        self.assertTrue(YuppTV.can_handle_url('https://www.yupptv.com/channels/india-today-news/news/25326023/15-jun-2018'))
-
-    def test_can_handle_negative(self):
-        # shouldn't match
-        self.assertFalse(YuppTV.can_handle_url('https://ewe.de'))
-        self.assertFalse(YuppTV.can_handle_url('https://netcologne.de'))
-        self.assertFalse(YuppTV.can_handle_url('https://zattoo.com'))
+        should_match = [
+            'https://www.yupptv.com/channels/etv-telugu/live',
+            'https://www.yupptv.com/channels/india-today-news/news/25326023/15-jun-2018',
+        ]
+        for url in should_match:
+            self.assertTrue(YuppTV.can_handle_url(url))
+
+    def test_can_handle_url_negative(self):
+        should_not_match = [
+            'https://ewe.de',
+            'https://netcologne.de',
+            'https://zattoo.com',
+        ]
+        for url in should_not_match:
+            self.assertFalse(YuppTV.can_handle_url(url))