reduzent/watchteleboy

Error after selecting show

alexzeitgeist opened this issue · 11 comments

I was able to login using my credentials. But after selecting a station, the script (v1.22) fails with the following error:

$ ./watchteleboy 
Already logged in as aaa@bbb.ccc
bash: [: http://...ip...:80/session/...long...session...string.../index.m3u8?startTime=1timestamp&mode=4&p=127: integer expression expected
could not download: #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1368000

I can't reproduce this on any of the following systems: Debian Jessie, Ubuntu 16.04, Mac OS X 10.10.

The first line of error looks like an URL of a variant index (the playlist containing the various stream variants with different bitrates). The second line suggests that the parsing of that playlist file failed and it passed line containing the stream info instead of the stream url

#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1368000

This is part of an index file. It's hard to tell, where it fails exactly, since bash doesn't give any line number, but it might be somewhere in function dump_hls_stream where the stream_variant is selected (line 633).

Do you use a non-common version of sed or grep?
Do you have special settings in your environment, in your ~/.bashrc ?
Can you tell me your OS and version of OS?

I suggest you try to run the script under a different user (on the system, not different Teleboy user), a user with a default environment as provided by your OS. Please report back, if it works with another user.

Hi,

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04 LTS"

Using the standard Ubuntu packages of sed, grep, etc.

As suggested I created a test user. Almost the same error:

$ ./watchteleboy 
Already logged in as aaa@bbb.ccc
bash: /tmp/watchteleboy/aaa@bbb.ccc/3+HD-201606231501.m2t: Permission denied
bash: [: http://...ip...:80/session/...long...session...string.../index.m3u8?startTime=1466675700&mode=4&p=127: integer expression expected
could not download: #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1368000

Only this time it also complains about a no permission issue.

FWIW (not sure if it makes a difference), I am on the TB comfort plan.

Ok, thanks. It doesn't look like an environment issue, then.

Never had the chance to test with a Teleboy Plus account. I wouldn't have expected any issue regarding Plus account, though.

Can you make another test for me, please? Does it work for you, if you use a non-Plus account? You can easily create one within a minute. You have to edit ~/.watchteleboyrc manually to make watchteleboy use the new account.

Ah, i forgot to mention:
You also have to delete all cached files:
rm -rf /tmp/watchteleboy/

Hi,

I created a new Teleboy free account, and it works. So I ran a wireshark dump to compare the responses.

Parts of the json-encoded data look different when queried in the teleboy_set_stream_data. Specifically:

Free account:

"stream":{
    "url":"http:\/\/teleboy.customers.cdn.iptv.ch\/1\/1008\/index.m3u8?p=127\u0026token=<tokenid>\u0026expires=1466774853\u0026c=t1",
    "alternative":false,
    "type":"live",
    "offset_before":300,
    "offset_after":0
}, ...

Comfort account:

"stream":{
    "url":"http:\/\/teleboy.customers.cdn.iptv.ch\/1\/1008\/index.m3u8?expires=1466776179\u0026startTime=1466684100\u0026token=<tokenid>\u0026p=127\u0026mode=4\u0026c=t1\u0026playPosition=5679",
    "alternative":false,
    "type":"live",
    "offset_before":300,
    "offset_after":0,
    "extra_timeshift":300
}, ...

The url contains several extra parameters in the comfort account that are related to the timeshift feature I suppose.

Your script then continues querying the stream url. The result again looks slightly different.

Free account:

#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=394000
http://<ip1>:80/session/<sessionid1>/nvnv5a/1/1008/394000/index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=540000
http://<ip1>:80/session/<sessionid1>/nvnv5a/1/1008/540000/index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1368000
http://<ip1>:80/session/<sessionid1>/nvnv5a/1/1008/1368000/index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2290000
http://<ip1>:80/session/<sessionid1>/nvnv5a/1/1008/2290000/index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=3305000
http://<ip1>:80/session/<sessionid1>/nvnv5a/1/1008/3305000/index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=4240000
http://<ip1>:80/session/<sessionid1>/nvnv5a/1/1008/4240000/index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=64000
http://<ip1>:80/session/<sessionid1>/nvnv5a/1/1008/64000/index.m3u8

Comfort account:

#EXTM3U
#EXT-X-START:TIME-OFFSET=5679.000
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=394000
http://<ip2>:80/session/<sessionid2>/nvnv5a/1/1008/394000/index.m3u8?startTime=1466684100&mode=4&p=127
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=540000
http://<ip2>:80/session/<sessionid2>/nvnv5a/1/1008/540000/index.m3u8?startTime=1466684100&mode=4&p=127
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1368000
http://<ip2>:80/session/<sessionid2>/nvnv5a/1/1008/1368000/index.m3u8?startTime=1466684100&mode=4&p=127
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2290000
http://<ip2>:80/session/<sessionid2>/nvnv5a/1/1008/2290000/index.m3u8?startTime=1466684100&mode=4&p=127
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=3305000
http://<ip2>:80/session/<sessionid2>/nvnv5a/1/1008/3305000/index.m3u8?startTime=1466684100&mode=4&p=127
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=4240000
http://<ip2>:80/session/<sessionid2>/nvnv5a/1/1008/4240000/index.m3u8?startTime=1466684100&mode=4&p=127
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=64000
http://<ip2>:80/session/<sessionid2>/nvnv5a/1/1008/64000/index.m3u8?startTime=1466684100&mode=4&p=127

For the comfort account, the extra parameters are included again, and also one additional line - #EXT-X-START:TIME-OFFSET=5679.000. Here is where the script stumbles somewhere when it's trying to extract the proper stream URL.

Also, on several occasions the script ignores the user-agent $UAGENT variable, i.e. it's not included when curl is called. For example in the teleboy_set_stream_data function.

Fixed in 71f0a8a

Cool. I am sorry for for not opening a new ticket regarding the missing curl headers. Have you looked at the Wireshark trace above when using a non-free account?

It seems the reason it fails with a TeleboyPlus account is that the variants playlist file has an additional line which is not handled by sed.

Commit f341ec5 tries to address this. Can you check, if this is already sufficient to make it work with Plus accounts?

Thanks

Unfortunately I don't have the Plus account anymore to be able to test it.

Nevermind. If any watchteleboy user actually has a Plus account, they might re-open the issue, if it doesn't work.

I close it for now.