reduzent / watchteleboy

Script to watch streams from teleboy.ch without browser/flash
GNU General Public License v2.0
31 stars 10 forks source link

watchteleboy fails after selecting a channel #29

Closed reduzent closed 4 years ago

reduzent commented 4 years ago

watchteleboy doesn't seem to work anymore since yesterday (2019-12-15). Login seems to work still fine, so does the parsing of the channel list. However, when it comes to play a selected channel, watchteleboy exits with the message:

not a valid playlist file

After a quick look into the issue, it appears that teleboy.ch switched from the Apple HLS protocol to the MPEG-DASH.

stahlnow commented 4 years ago

i found out i could play it back by putting streamlink -p mpv $master_url 720p just before the error message. quick hack until a fix ..

lcapriotti commented 4 years ago

Nice :) I think streamlink is huge and brings in lots of libraries, I am trying with ffmpeg inside dump_hls_stream:

ffmpeg -allowed_extensions ALL -i "$HLS_MASTER_URL" -c copy pipe:1

but no success so far (404 when opening video stream).

reduzent commented 4 years ago

Unfortunately, neither mpv nor ffmpeg are able to play the manifest (MPD-file) from the stream url. It seems not too hard, to parse the file and download the segments in the script. I have a very basic version written in Python working. I take the chance to switch to Python since the script has grown too large and I began to find it ugly in bash. I'm not an experienced programmer, so please bear with me.

Make sure to set TELEBOY_LOGIN and TELEBOY_PASS in watchteleboy. To get a list of channels, do:

./watchteleboy -l

To play a channel, do:

./watchteleboy -c <CHANNELNAME>

You'll find the draft in the branch #mpegdash#

lcapriotti commented 4 years ago

If you go that way I would suggest to rely on streamlink for the MPD parsing and video streaming (via ffmpeg), it just works. This would limit the extent of the complexity of the new script as only the login phase and retrieving the MPD will be in scope.

reduzent commented 4 years ago

@lcapriotti, thanks for the input. I certainly will checkout out streamlink and the python3-streamlink module. With "hand-knitted" implementation of the HLS protocol, I was able to exploit the fact, that stream content was cached on the servers for up to six hours. This allowed watchteleboy to let you watch content after it has been broadcasted. Since the switch to MPEG-DASH, content is delivered from different servers and it seems they cache broadcasted content only for three hours. Anyway, I would like to keep that feature of watching shows later. If streamlink doesn't let me use "old" timestamps, I'll probably stick to my "hand-knitted" mpd parser.

reduzent commented 4 years ago

@stahlnow What version of streamlink are you using? The one delivered with Ubuntu 18.04 doesn't seem to handle such URLs properly.

user@box:~$ streamlink -p mpv "http://zh2-9-dash-live.zahs.tv/HD_zdfinfo/manifest.mpd?z32=MF2WI2LPL5RW6ZDFMNZT2YLBMMTGG43JMQ6TCNKFIEYEMQRXIQ3TKNJWGI4TSLJUGNCTIRCBIFDDKN2CHBBUEQJTEZWWC6DSMF2GKPJVGAYDAJTNNFXHEYLUMU6TEMJQEZYHEZLGMVZHEZLEL5WGC3THOVQWOZJ5MRSSM43JM46TOOJUG5TDIZLFMVQTANDEGU4WCNLCGI2DMNDEGNTDEYZZMRRDIZJGOVZWK4S7NFSD25DFNRSWE33ZL43TSMRTHA4A" 720p
error: No plugin can handle URL: http://zh2-9-dash-live.zahs.tv/HD_zdfinfo/manifest.mpd?z32=MF2WI2LPL5RW6ZDFMNZT2YLBMMTGG43JMQ6TCNKFIEYEMQRXIQ3TKNJWGI4TSLJUGNCTIRCBIFDDKN2CHBBUEQJTEZWWC6DSMF2GKPJVGAYDAJTNNFXHEYLUMU6TEMJQEZYHEZLGMVZHEZLEL5WGC3THOVQWOZJ5MRSSM43JM46TOOJUG5TDIZLFMVQTANDEGU4WCNLCGI2DMNDEGNTDEYZZMRRDIZJGOVZWK4S7NFSD25DFNRSWE33ZL43TSMRTHA4A
user@box:~$ streamlink --version
streamlink 0.10.0
lcapriotti commented 4 years ago

correct, you need 1.3.0, either using pip or http://ppa.launchpad.net/nilarimogard/webupd8/ubuntu. I got trapped as well...

reduzent commented 4 years ago

wow.. streamlink is a really cool tool. Thanks for bringing it up

reduzent commented 4 years ago

streamlink does some magic to merge the two separate streams for audio and video into one single stream, so that it can pipe it to mpv's stdin. However, it doesn't take care of syncing audio and video. Unfortunately, audio segments have a duration of 3200ms and video segments a duration of 4000ms. They line up by chance sometimes, but often they do not. Also, I don't see a way to play "old" segments with streamlink. I probably stick to my own implementation (for now at least), as I am definitely not experienced enough to fix streamlink. It's not even that much code, since it doesn't try to be a generic mpd parser. And for me, it's an interesting project to get more accustomed to Python.

lcapriotti commented 4 years ago

I do have proper sync between audio & video with some custom ffmpeg parameters (I shall do a pull request for streamlink). But hey, if you manage on your own it's good to have options :)

reduzent commented 4 years ago

I've written a new version in Python. It is still a bit rough around the edges and I haven't thought about how to properly install it system-wide, but it seems to work so far with a similar set of options as before. Scheduling recordings is still work in progress. Also, it lacks an interactive CLI interface. Use the command line arguments for now.