Repository: streamlink/streamlink

Issue:
vaughnlive plugin is buggy
### Checklist

- [x] This is a bug report.
- [x] This is a feature request.
- [ ] This is a plugin (improvement) request.
- [x] I have read the contribution guidelines.

### Description

vaughnlive streams may not work all the time as it shows not found

### Expected / Actual behavior

...

### Reproduction steps / Explicit stream URLs to test

1. vaughnlive.tv/sherming66

### Environment details

Operating system and version: Windows 7
Streamlink and Python version: 0.6.0

### Comments, logs, screenshots, etc.




Discussion:
Could you please include what is printed out on the console when it does not work?  Would you also be able to run it with `-l debug` and comment back what it says, there should be quite a bit if debug information. 
it prints out connection failed message sometimes when I open a vaughnlive stream.
When it happens again can you copy the full message here, and if possible use the `-l debug` option as that will give us a much better idea of what is going wrong. 
ok thanks. @beardypig 
Vaughnlive recently switched to a HTML player from Flash, so that could be part of the issue. It says "no playable streams"

I got no extra meaningful output by applying the debug flag, but I could have done it incorrectly.

Edit: The correct syntax is:
streamlink -l debug http://vaughnlive.tv/newzviewz/old best
Might as well add it to all my .bat bookmarks. 

![screenshot001](https://user-images.githubusercontent.com/12178152/27619691-4f6391d0-5b92-11e7-8cda-5b1a282c9f96.jpg)

Will monitor this with interest. Thanks for looking!


Ah OK, I didn't know that - I haven't actually been able to check the website. Sounds like we might need a rewrite of the plugin if they have finally stopped using flash! 
Seems they are still broadcasting a flash stream. If one appends /old to any Vaughnlive URL it'll access a flash version of the stream that'll work with Streamlink. Don't know how long it'll work.

Edit: Worked for about 4 days? 
I can attest to techNeffect's comment. If you attach /old to the URL, it works immediately but fails with the mentioned above error if you don't.
For me, it stopped working yesterday. This is the message I'm receiving. Curiously, even when I'm not using the '/old' appendix, the website still uses a Flash Player (on Firefox, at least):

```
C:\>streamlink vaughnlive.tv/erobtv/old live
[cli][info] Found matching plugin vaughnlive for URL vaughnlive.tv/erobtv/old
[plugin.vaughnlive][info] Found player_version=0.1.1.796, info_url_domain=mvn.va
ughnsoft.net, info_url_path=None
[plugin.vaughnlive][error] Could not detect info_url_path
error: No playable streams found on this URL: vaughnlive.tv/erobtv/old
```
Looks like the player has changed more than expected. I'll take a look at the html player soon :-)
@beardypig Thanks  a lot for you effort!
If it's any help, a buddy of mine is reporting that the /old with livestreamer 1.12.2 is working still with /old but streamlink is not.
Getting the same error as @EFEVE though it still seems to be pulling up the flash player whenever I go to the site (on chrome) even without having the "/old" prefix. Hope this can be fixed soonish as I despise the vaughnlive site.
@JourneyOver I despise vaughnlive and their constantly changing crappy design choices! (though this change is to HTML5 so that's nice) :)
Looks like the HTML5 player use WebSocket protocol (WSS) to get the m3u8 url.
Example:
Connect to >  wss://sapi-ws-1x02.vaughnlive.tv
Send > MVN LOAD2 #vl-jandjtrip
Response > ACK2 #vl-jandjtrip;70;**CjAMPHqs2EVfoZ9FyKUI1vQehFWS5sNS**;**5940d648b3929**;0;1;1;0;ord
And the m3u8 url will be: 5940d648b3929.streamlock.net/live/live_jandjtrip/playlist.m3u8?CjAMPHqs2EVfoZ9FyKUI1vQehFWS5sNS
Vaughnlive is back to using /old on the http website to access flash, but it no longer works in streamlink as others have said. Defaults to HTML 5 when using browser as normal.

When they reverted back to flash player a few days ago you could use /hls to access the HTML 5 player. It may do so again, so that may help in your testing if so.

Current output, targeting /old site: 

![screenshot001](https://user-images.githubusercontent.com/12178152/27846078-adafd012-6102-11e7-95df-9ff94d14c282.jpg)

Thanks for looking, as always.
Looks like they had an updated noting everyone should swap over for html5 by June 26th: https://blog.vaughnsoft.com/2017/06/17/video-encoder-settings/ so the plugin will need to be reworked. This is actually a pretty big improvement considering the headache vaughnlive has been in the past.
For whatever it's worth, I tried with @techNeffect method of using /hls and got a different error.

```
C:\>streamlink vaughnlive.tv/erobtv/hls live
[cli][info] Found matching plugin vaughnlive for URL vaughnlive.tv/erobtv/hls
error: No playable streams found on this URL: vaughnlive.tv/erobtv/hls
```
Hey @beardypig and @techNeffect  when the vaughnlive plugin is gonna be fixed because i hate using flash player on vaughnlive site because it really slows down the pc and uses up a lot of cpu usage. Plz help me guys thanks.
@bobvargas Someone will fix it when they have time to do so. Please remember that we are unpaid volunteers and this is an open source project that people work on in their spare time. If you would like to place a bounty on this issue feel free to do so here: https://www.bountysource.com/issues/46548041-vaughnlive-plugin-is-buggy. Otherwise it's all down to when someone has the time and interest to fix it.
@bobvargas, @gravyboat has already explained this in one of your other threads:
https://github.com/streamlink/streamlink/issues/315#issuecomment-269572638

As [someone who's opened a couple of issues here](https://github.com/streamlink/streamlink/issues?utf8=%E2%9C%93&q=is%3Aissue%20author%3Abobvargas%20), you could consider [supporting the people](https://www.bountysource.com/teams/streamlink) who are spending their time on solving these issues. Apart from that, Streamlink is still an open source software project with a [permissive license](https://github.com/streamlink/streamlink/blob/master/LICENSE), which means that you can always fix plugins or any kind of bug by yourself and contribute back to the project if you want to.
ok thanks guys.
Hi there,

I have found a temporary solution until masters @beardypig and @gravyboat can fix the problem with streamlink plugin.

In order to play vaughnlive streams, just use the /old url and livestreamer with this [script](https://raw.githubusercontent.com/intact/livestreamer/fix-vaughn/src/livestreamer/plugins/vaughnlive.py). Example of command:

`livestreamer --plugin-dirs "Directory where vaughnlive.py file is found" http://vaughnlive.tv/newzviewz/old worst | vlc -
`
![screenshot from 2017-07-11 15-07-01](https://user-images.githubusercontent.com/28090483/28069731-cee07f5a-664a-11e7-8d7c-f14b08953265.png)

Hope this helps :D
so @skilleek method works for the time being, you don't need to download livestreamer at all though. 

what you can do is download the script from his link and put it in the plugins folder for streamlink (Default for me was "C:\Program Files (x86)\Streamlink\pkgs\streamlink\plugins"), rename the old plugin to vaughnlive.py.bak (or just replace the old script with the one from the script above) and then go into the new script and replace 
```
from livestreamer.plugin import Plugin
from livestreamer.plugin.api import http, validate
from livestreamer.stream import RTMPStream
```
to 
```
from streamlink.plugin import Plugin
from streamlink.plugin.api import http, validate
from streamlink.stream import RTMPStream
```
@skilleek method works perfectly, even more so with @JourneyOver 's correction, you don't even need to put '/old' at the end of the link.
It's broken again after today's update. The script returns with the error "No data returned from stream" now. I decompiled VaughnSoftPlayer.swf and it seems changes have been made in the way the player obtains the streaming server URL and the stream token. I believe it no longer uses INFO_URL to get this information. Instead, it uses an external call to MvnApi.getFlashData(). The output of this function can be seen on the console when loading a channel page, it looks like this:

VTrace: flashData: 5940d648b3929;1tn5MjdACmQRLjmaJtWdPdMV7LeIDupG

The part before the semicolon is the encoded streaming server IP and the part after it is the token. The correspondence between encoded and plain server IP is readily available from the decompiled source but I don't know if there is a way to call MvnApi.getFlashData() from a Python script, especially if this is prevented by the settings in crossdomain.xml.

Of course, this only applies to the flash player which may soon be deprecated altogether.
@fadster Yeah if we're going to fix it then it might as well be changed to no longer support the flash player, moving to an html5 player is the first thing that vaughnlive has done in a while that hasn't been annoying in terms of Streamlink functionality. Thanks for putting the time in to take a look and see what's up with it!
@gravyboat Well, flash or html5, all we really want is a stream URL to pass to an external player. :smile: You're welcome! I'll report back if I find anything useful.
bet once they do finally move everything over to the html5 player they are still going to try and fuck with livestreamer/streamlink a ton just because they want their stupid ad money :/
@JourneyOver I can't really blame them for wanting to stay fed with the hard work they're doing. It's one of the reasons we encourage people to donate to streaming services they like when possible. Without those ads/donations/subscriptions the services won't exist for us to help people stream!
And it's completely broken now
@kargaroc Yeah they probably phased out the flash player completely in favor of their html5 player.
Actually it still begs for me to install Flash at the moment.  Being on Linux, I have no way of watching their streams anymore until this plugin gets fixed or replaced, or they actually enable their HTML5 player.
@kargaroc Yeah if you aren't willing to make Flash happen and their HTML5 player doesn't work properly for you there's not much we can do. If someone wants to update the plugin they'll say so. You can also place a bounty on this issue if you would like: https://www.bountysource.com/issues/46548041-vaughnlive-plugin-is-buggy
@kargaroc I know what you mean there.

Technically Chrome on Linux is supposedly supposed to have Flash but it doesn't always seem to be properly detected by various websites which act like you don't have Flash and need an upgrade.

To remedy this and it has worked for me for Vaughlive in the past is, use Opera Mini for Linux if you do want to watch Vaughlive streams on your Linux PC in the mean time.
They have indeed reverted to the flash player on the main site but the embeds use the html5 player. The old INFO_URL used by the streamlink plugin to get the stream URL now returns a 404 so that mechanism seems to have been phased out altogether. Even though the new implementation might make things a bit more difficult, I'm fairly certain we can still get this information but I haven't looked much into it. The comment made by @RosadinTV regarding the way the html5 player gets the m3u8 URL could be our most promising avenue.
Guys,

With the modifications they have been making, now it's possible to catch it again, just add the referer:

`streamlink --http-header "Referer=http://vaughnlive.tv/newzviewz" "hls://https://hls-ord-2a.vaughnsoft.net/nyc/live/live_newzviewz/chunklist.m3u8" best`

![screenshot from 2017-07-17 15-07-05](https://user-images.githubusercontent.com/28090483/28269319-e4251e6e-6b01-11e7-8b71-1b011b5bf80b.png)

Hopefully this will be a more permanent solution. I am glad to help you all and encourage people to keep collaborating to improve streamlink :D
I'm working on an updated version of the plugin using the new websocket API. `newzviewz` is actually a special case and handled slog differently to some of the other channels. Some channels are only available via rtmp and not hls, but some support both. Hopefully I'll PR an updated plugin in the next couple of days. 
@skilleek How do you find the server for a given channel? I got a 404 when I tried your method on other channels that have been switched to hls (eg. kingthehilltv1).
Most streams are on all servers, but you need to know the `ingest` part. In the case of `newzviewz` it's `nyc`, and for `kingthehilltv1` it's `ord`, so 
```
streamlink --http-header "Referer=http://vaughnlive.tv/kingthehilltv1" "hls://https://hls-ord-2a.vaughnsoft.net/ord/live/live_kingthehilltv1/chunklist.m3u8" best
```
should work. To find out the `ingest` part, you need to consult the API :) 
@beardypig Thanks! I don't know if there's a better way to find out but I got the info from looking at the console output on a channel page.
Yep, you can get it from the console - for the plugin it will use the API :)
how about sherming66 url? i tried to stream it.
@bobvargas Look at the console output in your browser, you'll find all the info you need.

    streamlink --http-header "Referer=http://vaughnlive.tv/sherming66" "hls://https://hls-ord-2a.vaughnsoft.net/ord/live/live_sherming66/chunklist.m3u8" best
ok i'll try thanks

yep it works thank you @fadster.
@fadster  It is working ^^. Same here, ありがとう :)
Looks like they also fixed the exploit url as well :(

Hey @fadster  sometimes the url you gave (streamlink --http-header "Referer=http://vaughnlive.tv/newzviewz" "hls://https://hls-ord-2a.vaughnsoft.net/nyc/live/live_newzviewz/chunklist.m3u8" best) can sometimes bring up a 404 error other times it may work. Hopefully a full plugin fix would resolve it soon.

Oh btw vaughnlive on streamlink is fully broken because of no flash player version appearing at all :(

C:\Users\Bob>streamlink vaughnlive.tv/sherming66 live
[cli][info] Found matching plugin vaughnlive for URL vaughnlive.tv/sherming66
error: No playable streams found on this URL: vaughnlive.tv/sherming66 and the url you gave return an error...

C:\Users\Bob>streamlink --http-header "Referer=http://vaughnlive.tv/sherming66"
"hls://https://hls-ord-2a.vaughnsoft.net/ord/live/live_sherming66/chunklist.m3u8
" best
[cli][info] Found matching plugin stream for URL hls://https://hls-ord-2a.vaughn
soft.net/ord/live/live_sherming66/chunklist.m3u8
[cli][info] Available streams: live (worst, best)
[cli][info] Opening stream: live (hls)
[cli][error] Try 1/1: Could not open stream <HLSStream('https://hls-ord-2a.vaugh
nsoft.net/ord/live/live_sherming66/chunklist.m3u8')> (Could not open stream: Una
ble to open URL: https://hls-ord-2a.vaughnsoft.net/ord/live/live_sherming66/chun
klist.m3u8 (404 Client Error: Not Found for url: https://hls-ord-2a.vaughnsoft.n
et/ord/live/live_sherming66/chunklist.m3u8))
error: Could not open stream <HLSStream('https://hls-ord-2a.vaughnsoft.net/ord/l
ive/live_sherming66/chunklist.m3u8')>, tried 1 times, exiting

I don't know if vaughnlive has officially gone all html5 or what. let me know if there's a fix soon
@bobvargas The error you're getting just means the stream is currently offline.
@fadster just kidding i found the problem it was (streamlink --http-header "Referer=http://vaughnlive.tv/sherming66" "hls://https://hls-ord-2a.vaughnsoft.net/den/live/live_sherming66/chunklist.m3u8" best) not (streamlink --http-header "Referer=http://vaughnlive.tv/sherming66" "hls://https://hls-ord-2a.vaughnsoft.net/ord/live/live_sherming66/chunklist.m3u8" best) now it finally works sorry @fadster for the other post I made eariler.
The stream is on a different ingest server now so the URL changed. As was mentioned in previous comments, you can get this information by looking at the console output in your browser's developer tools. The command for that stream is now:

    streamlink --http-header "Referer=http://vaughnlive.tv/sherming66" "hls://https://hls-ord-2a.vaughnsoft.net/den/live/live_sherming66/chunklist.m3u8" best

Note the change from `ord` to `den`, as indicated by the following line printed on the console when you load the channel's page:

    >>> hlsServer: hls-ord-2a.vaughnsoft.net/den

streamlink now seems to need hlsvariant:// instead of hls://:
`[cli][error] Try 1/1: Could not open stream <HLSStream('https://hls-ord-4a.vaughnsoft.net/den/live/live_sherming9/playlist.m3u8')> (Could not open stream: Attempted to play a variant playlist, use 'hlsvariant://https://hls-ord-4a.vaughnsoft.net/den/live/live_sherming9/playlist.m3u8' instead)`
@rtega for `playlist.m3u8`, yes you will need to use `hlsvariant`, but if you use the `chunklist.m3u8` url you will need to use `hls`. 
Just to quickly explain hls:// vs hlsvariant:// for anybody, because I was confused for a second when I first seen it, but hls:// is for a single bitrate/resolutions playlist while hlsvariant:// is for a playlist with multiple bitrates/resolutions.

You can tell if you open the m3u8 in a text editor if it is single or variant.
just to let you know @fadster's vaughnlive url treak also works with livestreamer.

However some questions to ask do Vaughnlive flash url version works though?

And if using the new url exploit does it doss the broadcaster?
@bobvargas you mean the rtmp URLs? They still exist, at least for the channels I have tried, but getting the rtmp URL is not as simple. 

Using the rtmp  or hls stream will not doss the broadcaster, the broadcasts stream to vl and then vl re-stream it to you. The broadcaster only sends the stream once, so 0 or a 1,000 viewers makes no difference to the broadcaster. 
Any progress made to fix vaughnlive stream yet?

Oh Btw sometimes some vaughnlive broadcasters can have multiple servers working besides the main one.

Example

>>> hlsServer: hls-ord-2a.vaughnsoft.net/ord

![image](https://user-images.githubusercontent.com/24505327/28490429-17b02342-6ea8-11e7-8122-ec38ac27d858.png)

![image](https://user-images.githubusercontent.com/24505327/28490439-374c393e-6ea8-11e7-8a6b-b504827b1e00.png)

![image](https://user-images.githubusercontent.com/24505327/28490446-5a378250-6ea8-11e7-94de-e4e4c54fd254.png)

I tried it multiple vaughnlive servers and sometimes these 3 servers work even if it not ord.

Well here's something to think about @fadster  @beardypig let's use to following url

C:\Users\SUS>streamlink --http-header "Referer=http://vaughnlive.tv/sherming66"
"hls://https://sherming66;7;100;itojBxGRAWsyyUozOddeW75NufwmPLdO;594140c69edad;0
;1;1;0;ord
if this work it may use to stream the flash player version as well... plz post.

Well here's something to think about @fadster  @beardypig let's use to following url

C:\Users\SUS>streamlink --http-header "Referer=http://vaughnlive.tv/sherming66"
"hls://https://sherming66;7;100;itojBxGRAWsyyUozOddeW75NufwmPLdO;594140c69edad;0
;1;1;0;ord
if this work it may use to stream the flash player version as well... 

Hey @beardypig How do you find the rtmp url on vaughnlive plz help me.

@bobvargas Please don't tag people in two comments like that (edit instead), and don't close this as it isn't fixed. Please remember this is an unpaid 'job' we do on the side, and we all have lives to live. 
@bobvargas please wait a few days while I complete the plugin. 
@gravyboat sorry about that.

And one last thing the url that @fadster given was a html 5 version of the stream. Hopefully the fixed plugin would still use rtmp (flash streams) because the html 5 version still have buffering issues for a channel.
@bobvargas The new version won't support flash as far as I know (@beardypig can probably confirm). Vaughn is basically EOL'ing their flash stuff.
The site is now defaulting to a new flash player. The html5 player is still accessible by adding /hls to a channel's URL (https://www.facebook.com/thevaughn/posts/10159028932310640). 

Note that for some channels I've had to use `hlsvariant` with `playlist.m3u8` as `hls` with `chunklist.m3u8` was timing out. This could just be a transient glitch though.
Hi @Fadster i was wondering do you have a url fix for rtmp flash streams on vaughnlive because the html5 streams keeps buffering every 15 minutes. Even your hls method still has buffering issue because of html 5 servers/ player of vaughnlive plz give us a flash rtmp streams url thanks.
@fadster which channels did you have to use the `playlist.m3u8` url for?


Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -44,6 +44,8 @@
     deps.append("iso-639")
     deps.append("iso3166")
 
+deps.append("websocket-client")
+
 # When we build an egg for the Win32 bootstrap we don't want dependency
 # information built into it.
 if environ.get("NO_DEPS"):
diff --git a/src/streamlink/plugins/vaughnlive.py b/src/streamlink/plugins/vaughnlive.py
--- a/src/streamlink/plugins/vaughnlive.py
+++ b/src/streamlink/plugins/vaughnlive.py
@@ -1,122 +1,106 @@
 import random
 import re
+import itertools
+import ssl
+import websocket
 
 from streamlink.plugin import Plugin
-from streamlink.plugin.api import http, validate
+from streamlink.plugin.api import useragents, http
 from streamlink.stream import RTMPStream
-from streamlink.utils import swfdecompress
-
-INFO_URL = "http://{site}{path}{domain}_{channel}?{version}_{ms}-{ms}-{random}"
-
-DOMAIN_MAP = {
-    "breakers": "btv",
-    "vapers": "vtv",
-    "vaughnlive": "live",
-}
 
 _url_re = re.compile(r"""
     http(s)?://(\w+\.)?
-    (?P<domain>vaughnlive|breakers|instagib|vapers).tv
+    (?P<domain>vaughnlive|breakers|instagib|vapers|pearltime).tv
     (/embed/video)?
     /(?P<channel>[^/&?]+)
 """, re.VERBOSE)
 
-_swf_player_re = re.compile(r'swfobject.embedSWF\("(/\d+/swf/[0-9A-Za-z]+\.swf)"')
-
-_schema = validate.Schema(
-    validate.any(
-        validate.all(u"<error></error>", validate.transform(lambda x: None)),
-        validate.all(
-            validate.transform(lambda s: s.split(";")),
-            validate.length(3),
-            validate.union({
-                "server": validate.all(
-                    validate.get(0),
-                    validate.text
-                ),
-                "token": validate.all(
-                    validate.get(1),
-                    validate.text,
-                    validate.startswith(":mvnkey-"),
-                    validate.transform(lambda s: s[len(":mvnkey-"):])
-                ),
-                "ingest": validate.all(
-                    validate.get(2),
-                    validate.text
-                )
-            })
-        )
-    )
-)
+
+class VLWebSocket(websocket.WebSocket):
+    def __init__(self, **_):
+        self.session = _.pop("session")
+        self.logger = self.session.logger.new_module("plugins.vaughnlive.websocket")
+        sslopt = _.pop("sslopt", {})
+        sslopt["cert_reqs"] = ssl.CERT_NONE
+        super(VLWebSocket, self).__init__(sslopt=sslopt, **_)
+
+    def send(self, payload, opcode=websocket.ABNF.OPCODE_TEXT):
+        self.logger.debug("Sending message: {0}", payload)
+        return super(VLWebSocket, self).send(payload + "\n\x00", opcode)
+
+    def recv(self):
+        d = super(VLWebSocket, self).recv().replace("\n", "").replace("\x00", "")
+        return d.split(" ", 1)
 
 
 class VaughnLive(Plugin):
+    api_re = re.compile(r'new sApi\("(#(vl|igb|btv|pt|vtv)-[^"]+)",')
+    servers = ["wss://sapi-ws-{0}x{1:02}.vaughnlive.tv".format(x, y) for x, y in itertools.product(range(1, 3),
+                                                                                                   range(1, 6))]
+    origin = "https://vaughnlive.tv"
+    rtmp_server_map = {
+        "594140c69edad": "198.255.17.18",
+        "585c4cab1bef1": "198.255.17.26",
+        "5940d648b3929": "198.255.17.34",
+        "5941854b39bc4": "198.255.17.66"}
+    name_remap = {"#vl": "live", "#btv": "btv", "#pt": "pt", "#igb": "instagib", "#vtv": "vtv"}
+
     @classmethod
     def can_handle_url(cls, url):
         return _url_re.match(url)
 
-    def _get_streams(self):
-        res = http.get(self.url)
-        match = _swf_player_re.search(res.text)
-        if match is None:
-            return
-        swf_url = "http://vaughnlive.tv" + match.group(1)
-        self.logger.debug("Using swf url: {0}", swf_url)
-
-        swfres = http.get(swf_url)
-        swfdata = swfdecompress(swfres.content).decode("latin1")
-
-        player_version_m = re.search(r"0\.\d+\.\d+\.\d+", swfdata)
-        info_url_domain_m = re.search(r"\w+\.vaughnsoft\.net", swfdata)
-        info_url_path_m = re.search(r"/video/edge/[a-zA-Z0-9_]+-", swfdata)
-
-        player_version = player_version_m and player_version_m.group(0)
-        info_url_domain = info_url_domain_m and info_url_domain_m.group(0)
-        info_url_path = info_url_path_m and info_url_path_m.group(0)
-
-        if player_version and info_url_domain and info_url_path:
-            self.logger.debug("Found player_version={0}, info_url_domain={1}, info_url_path={2}",
-                              player_version, info_url_domain, info_url_path)
-            match = _url_re.match(self.url)
-            params = {"channel": match.group("channel").lower(),
-                      "domain": DOMAIN_MAP.get(match.group("domain"), match.group("domain")),
-                      "version": player_version,
-                      "ms": random.randint(0, 999),
-                      "random": random.random(),
-                      "site": info_url_domain,
-                      "path": info_url_path}
-            info_url = INFO_URL.format(**params)
-            self.logger.debug("Loading info url: {0}", INFO_URL.format(**params))
-
-            info = http.get(info_url, schema=_schema)
-            if not info:
-                self.logger.info("This stream is currently unavailable")
-                return
-
-            app = "live"
-            self.logger.debug("Streaming server is: {0}", info["server"])
-            if info["server"].endswith(":1337"):
-                app = "live-{0}".format(info["ingest"].lower())
-
-            stream = RTMPStream(self.session, {
-                "rtmp": "rtmp://{0}/live".format(info["server"]),
-                "app": "{0}?{1}".format(app, info["token"]),
-                "swfVfy": swf_url,
-                "pageUrl": self.url,
-                "live": True,
-                "playpath": "{domain}_{channel}".format(**params),
-            })
-
-            return dict(live=stream)
+    def api_url(self):
+        return random.choice(self.servers)
+
+    def parse_ack(self, action, message):
+        if action.endswith("3"):
+            channel, _, viewers, token, server, choked, is_live, chls, trns, ingest = message.split(";")
+            is_live = is_live == "1"
+            viewers = int(viewers)
+            self.logger.debug("Viewers: {0}, isLive={1}", viewers, is_live)
+            domain, channel = channel.split("-", 1)
+            return is_live, server, domain, channel, token, ingest
         else:
-            self.logger.info("Found player_version={0}, info_url_domain={1}, info_url_path={2}",
-                             player_version, info_url_domain, info_url_path)
-            if not player_version:
-                self.logger.error("Could not detect player_version")
-            if not info_url_domain:
-                self.logger.error("Could not detect info_url_domain")
-            if not info_url_path:
-                self.logger.error("Could not detect info_url_path")
+            self.logger.error("Unhandled action format: {0}", action)
+
+    def _get_info(self, stream_name):
+        server = self.api_url()
+        self.logger.debug("Connecting to API: {0}", server)
+        ws = websocket.create_connection(server,
+                                         header=["User-Agent: {0}".format(useragents.CHROME)],
+                                         origin=self.origin,
+                                         class_=VLWebSocket,
+                                         session=self.session)
+        ws.send("MVN LOAD3 {0}".format(stream_name))
+        action, message = ws.recv()
+        return self.parse_ack(action, message)
+
+    def _get_rtmp_streams(self, server, domain, channel, token):
+        rtmp_server = self.rtmp_server_map.get(server, server)
+
+        url = "rtmp://{0}/live?{1}".format(rtmp_server, token)
+
+        yield "live", RTMPStream(self.session, params={
+            "rtmp": url,
+            "pageUrl": self.url,
+            "playpath": "{0}_{1}".format(self.name_remap.get(domain, "live"), channel),
+            "live": True
+        })
+
+    def _get_streams(self):
+        res = http.get(self.url, headers={"User-Agent": useragents.CHROME})
+
+        m = self.api_re.search(res.text)
+        stream_name = m and m.group(1)
+
+        if stream_name:
+            is_live, server, domain, channel, token, ingest = self._get_info(stream_name)
+
+            if not is_live:
+                self.logger.info("Stream is currently off air")
+            else:
+                for s in self._get_rtmp_streams(server, domain, channel, token):
+                    yield s
 
 
 __plugin__ = VaughnLive


Test patch: