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

Support for wasd.tv #2636

Closed
Uinden opened this issue Sep 29, 2019 · 3 comments · Fixed by #2641
Closed

Support for wasd.tv #2636

Uinden opened this issue Sep 29, 2019 · 3 comments · Fixed by #2641

Comments

@Uinden
Copy link
Contributor

Uinden commented Sep 29, 2019

There is 2 type of links. For example:
https://wasd.tv/channel/86692/videos/269793
https://wasd.tv/channel/86692
Both of them can be live stream or replay of past stream.

What I will say next is not confirmed by any documentation or anything its just how I think this website working.

For example user call streamlink for URL https://wasd.tv/channel/86692
Then we request
https://wasd.tv/api/media-containers?media_container_status=RUNNING&limit=1&offset=0&channel_id=86692&media_container_type=SINGLE,COOP
Response is in JSON format.
*I replaced media_container_status=STOPPED,RUNNING to just RUNNING. I think if user calls streamlink without /videos/ part in URL he wants live stream. Not past record.
If there is no live stream then response will be {"result":[]}
From response we need json["result"][0]["user_id"]. For example this channel's user_id=179599
Then we look into array json["result"][0]["media_container_streams"] and search for element where json["result"][0]["media_container_streams"][i]["user_id"] is equals to channel's user_id=179599
Then inside that element of array we get another element json["result"][0]["media_container_streams"][i]["stream_media"] which has different streams with different quality. For example:
json["result"][0]["media_container_streams"][0]["stream_media"][0]["media_type"]="HLS"
json["result"][0]["media_container_streams"][0]["stream_media"][0]["media_status"]="RUNNING"
json["result"][0]["media_container_streams"][0]["stream_media"][0]["media_meta"]["media_current_resolution"]="1280x720"
json["result"][0]["media_container_streams"][0]["stream_media"][0]["media_meta"]["media_url"]="https://cdn.wasd.tv/live/179599/index.m3u8"

Now if user call streamlink for URL https://wasd.tv/channel/86692/videos/269793
We request https://wasd.tv/api/media-containers/269793
And its basically same response and we need to do same job here.
If this is live stream then in json["result"][0]["media_container_streams"][0]["stream_media"] array will be element with media_status="RUNNING"
If this is replay of past stream then in json["result"][0]["media_container_streams"][0]["stream_media"] array will be element with media_status="STOPPED"
And instead of media_url we need to get media_archive_url which will be .m3u8 file.

I have checked other plugins code and its too hard for me to make it myself.
I hope somebody will be able to do it with results of my "investigation".

@Uinden
Copy link
Contributor Author

Uinden commented Sep 29, 2019

I attempted to do it myself and it was easier than I expected until I got to HLS part.
This is my firs experience with streamlink and third time using python. And I have no idea how HLS works.
WASD has array of resolutions in its JSON files but I can't find stream with more that one resolution to select. Looks like they not implemented that yet.
So I just give streamlink first HLS URL that I find (there is only one at the moment) and it works. And even detects resolution using some HLS voodoo magic.
So it works, but I don't know if I did everything correctly.
Both live streams and records works.

@Uinden
Copy link
Contributor Author

Uinden commented Oct 2, 2019

Found stream with multiple resolution choices. And it works great, streamlink detects everything.

>streamlink https://wasd.tv/channel/1185
[cli][info] Found matching plugin wasd for URL https://wasd.tv/channel/1185
Available streams: 360p (worst), 480p, 720p (best)

I expected to see multiple stream_media elements in API (one for each resolution), but there is only one that says media_current_resolution: "1280x720".
So my assumption about multiple .m3u8 URLs for every quality was wrong. There is one .m3u8 link that includes all resolutions.

TL;DR: Plugin works better than I expected and no changes needed.

@Murloc111
Copy link

Murloc111 commented Nov 16, 2019

On line 131 and 139 wasd.py need replace to be work (on python 2.7):
stream["media_meta"]["media_current_resolution"]
to
str(stream["media_meta"]["media_current_resolution"])

back-to added a commit that referenced this issue Mar 21, 2020
closes #2636

Co-authored-by: back-to <backto@protonmail.ch>
Billy2011 pushed a commit to Billy2011/streamlink-27 that referenced this issue May 14, 2020
closes streamlink#2636

Co-authored-by: back-to <backto@protonmail.ch>
mkbloke pushed a commit to mkbloke/streamlink that referenced this issue Aug 18, 2020
closes streamlink#2636

Co-authored-by: back-to <backto@protonmail.ch>
resiproxy pushed a commit to resiproxy/streamlink that referenced this issue Nov 5, 2020
closes streamlink#2636

Co-authored-by: back-to <backto@protonmail.ch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants