Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get M3U8 Playlist from TVB
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;
public class Helper {
public enum Channel {HDJ, J2, INEWS};
public enum Quality {QUALITY_720P, QUALITY_360P};
private static String[] links720p = {"http://token.tvb.com/stream/live/hls/mobilehd_hdj.smil",
"http://token.tvb.com/stream/live/hls/mobilehd_jade.smil",
"http://token.tvb.com/stream/live/hls/mobilehd_j2.smil",
"http://token.tvb.com/stream/live/hls/mobilehd_inews.smil"};
private static String[] links360p = {"http://token.tvb.com/stream/live/hls/mobile_hdj.smil",
"http://token.tvb.com/stream/live/hls/mobile_jade.smil",
"http://token.tvb.com/stream/live/hls/mobile_j2.smil",
"http://token.tvb.com/stream/live/hls/mobile_inews.smil"};
public static String getPlaylist(Channel channel, Quality quality) {
try {
String[] links;
String link = null;
if (quality == Quality.QUALITY_720P){
links = links720p;
}else {
links = links360p;
}
switch (channel) {
case HDJ:
link = links[0];
break;
case J2:
link = links[1];
break;
case INEWS:
link = links[2];
break;
}
URL url = new URL(link);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setInstanceFollowRedirects(false);
int code = conn.getResponseCode();
Map map = conn.getHeaderFields();
if (code == 302) {
return map.get("Location").toString().replaceAll("\\[", "").replaceAll("\\]", "");
} else {
return link;
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
@seventhmoon

This comment has been minimized.

Copy link
Owner Author

commented Apr 27, 2016

As at 2016-04-27. All links are broken. Seems provider has closed all HLS media sources.

@Kyusuke

This comment has been minimized.

Copy link

commented May 2, 2016

If the HLS sources are closed, does this mean that the myTV iOS/Android app now use the Octoshape client to view the livestreams? Since the HLS streams were for the mobile clients as far as I know.

@Kyusuke

This comment has been minimized.

Copy link

commented May 6, 2016

Adding that gets me the playlist and the following chunk playlist as well but the .ts files seem to transfer extremely slow if at all.

@kk246

This comment has been minimized.

Copy link

commented May 7, 2016

@Kyusuke
How did you manage to get the playlist to load?
I only get a blank response using the links above in Firefox

@Kyusuke

This comment has been minimized.

Copy link

commented May 8, 2016

There was a comment previously (but now gone) that suggested appending ?app=mytv onto the .smil links. The blank responses you were having are 403 Forbidden errors while adding that parameter gets you the playlist.

@kk246

This comment has been minimized.

Copy link

commented May 8, 2016

@Kyusuke
Cheers! Thanks for that!

@shawn35

This comment has been minimized.

Copy link

commented May 8, 2016

@Kyusuke, may i khow how you get the link to work?below link i am not able to play it. Kindly advise.

http://token.tvb.com/stream/live/hls/mobilehd_jade.smil?app=mytv

@Kyusuke

This comment has been minimized.

Copy link

commented May 8, 2016

@kk246
Can you let me know if you can load the stream fine? I'm wanting to determine if the .ts files can be loaded without issue for HK IPs.

@shawn35
If you want to load the stream from that link, VLC player will open and play the link provided it's working which is not the case for me

@token-stranger

This comment has been minimized.

Copy link

commented May 8, 2016

Applying the following link in that manner
http://token.tvb.com/stream/live/hls/mobilehd_hdj.smil?app=mytv

resolves to
http://vdo-live-cache-akamai.cdn.tvb.com/mytvlive/smil:mobilehd_hdj.smil/playlist.m3u8?hdnea=st=1462739280~exp=1462750080~acl=/mytvlive/smil:mobilehd_hdj.smil/*~hmac=6b2b428c253da9baad4e4a7ff6df2fd062b1dc9d299b0589f02b35d1a4f93a6c

and using SmartDNS for Hong Kong status resolves to
http://202.126.56.112/session/9551f908-155b-11e6-8265-005056b15a5f/2ukcnb/mytvlive/smil:mobilehd_hdj.smil/playlist.m3u8?token=c295608fc1c36a0b01c070e3e7825986_1462825776_1462746576

Either way, it takes a long while for the video picture to show up and while good quality, it is static and has no audio. The video continue to load and when the "play" is selected, the video plays for an instant, then stops but the audio carries on merrily.

Unsure whether the delay is due to server issues or otherwise. I am not in Hong Kong and I ran this on the iCab browser on the iPad.

@Kyusuke

This comment has been minimized.

Copy link

commented May 8, 2016

I experimented with this a few months back with their on-demand content and found out that if I loaded up a video normally (from a non-HK address), it'll load but the transfer rate would be miniscule. If I used a VPN (e.g. ZenMate) and loaded the same link, the video would load fine so I was led to believe there was some sort of configuration done to severely limit the bandwidth transferred to non-HK IPs to an unusable rate.

I thought this would be apply likewise to this case but unless the IPs used by the VPN are affected, I'm thinking the video files would download at a snail's pace for everybody. Hence I'm wanting to know if anyone with a proper HK IP can view them without issue.

@token-stranger

This comment has been minimized.

Copy link

commented May 9, 2016

Further experiment - running same setup, but using Hong Kong proxy with openVPN (VPN Gate - University of Tsukuba, Japan). Link resolves first to a wowsa server (as against an Akamai server previously without VPN), then immediately to an IP number. Video and audio now loads fine - initial pixelation but the video cleared up right after. Likely geo-locked or throttled.

@Kyusuke

This comment has been minimized.

Copy link

commented May 9, 2016

Interesting, could you attempt to directly connect to the wowsa server without going through a VPN? I'm assuming that you'd get a 403 though

@shawn35

This comment has been minimized.

Copy link

commented May 12, 2016

actually is it mean that all these links will expire? and there is no permanent link?

@token-stranger

This comment has been minimized.

Copy link

commented May 12, 2016

Let's clarify.

  1. I am not in Hong Kong.
  2. The links appears to be geo-locked, so a Hong Kong proxy/ VPN (preferable) or a SmartDNS is needed for those outside of Hong Kong.
  3. I used the links listed above but added "?app=mytv" (without the quotation marks) to each link. Example,
    http://token.tvb.com/stream/live/hls/mobilehd_jade.smil?app=mytv
  4. This link will automatically re-direct to the wowsa server (happens almost immediately and may not be noticeable), and re-directs to an IP number, usually 202.126.xxx.xxx.
  5. I ran the links through an iPad, iPhone and an Android phone.
  6. It works better on iOS devices because .m3u8 formats are more native on Apple devices than Android's, especially when played through the Safari browser.
  7. Surprising, Jade and iNews streams are quick and extremely reliable. J2 and J5 are hits and misses, working periodically. Uncertain why.
  8. All re-directed links are not permanent, requiring new tokens each time.

I hope that answers most queries.

@shawn35

This comment has been minimized.

Copy link

commented May 16, 2016

@ token-strange. Thanks for your clarification. But i have one question. I have tried to use http://token.tvb.com/stream/live/hls/mobilehd_jade.smil?app=mytv and try to get the ip as you mention but i am unable to do so. I only able to get below link. Can you advise me how you get it?

http://vdo-live-cache-akamai.cdn.tvb.com/mytvlive/smil:mobilehd_hdj.smil/chunklist_b1536000.m3u8

@dpc27149

This comment has been minimized.

Copy link

commented May 17, 2016

Hi, the link is blocked....

@token-stranger

This comment has been minimized.

Copy link

commented May 17, 2016

@shawn35

I can only speak from experience. When I am not in Hong Kong, and I connect to

http://token.tvb.com/stream/live/hls/mobilehd_jade.smil?app=mytv

without a proxy/VPN or a smart DNS service, that link above will resolve to a similar link like what you have highlighted.

http://vdo-live-cache-akamai.cdn.tvb.com/mytvlive/smil:mobilehd_hdj.smil/chunklist_b1536000.m3u8?xxxxxxxxx

I cannot tell beyond what I don't know about. It's probably geo-location locked.

@shawn35

This comment has been minimized.

Copy link

commented May 17, 2016

@token-stranger,

Actually i use hongkong vpn to access the token link.....but it does not goes to the ip link that you mention. which is why i am wondering how you get the ip address link

@adamcheng1947

This comment has been minimized.

@dpc27149

This comment has been minimized.

Copy link

commented May 18, 2016

Are the links deleted? There's no vital sign!

@lingaoyi

This comment has been minimized.

Copy link

commented May 31, 2016

.......

@rainy1983

This comment has been minimized.

Copy link

commented Sep 23, 2016

TVB fix GOTV and MYTVSUPER.

@tokentvb

This comment has been minimized.

Copy link

commented Sep 25, 2016

GOTV and MYTVSUPER fix

@Kyusuke

This comment has been minimized.

Copy link

commented Nov 2, 2016

So I had some time to investigate this again. Funnily enough, if you can trick the myTV app into thinking it's inside HK (by returning a modified JSON response for example), you can still use the app like normal for live tv.
Accessing the URL stream itself isn't as simple as just loading it up now though, the way the app works is that it'll load up the URL like so:

http://token.tvb.com/stream/live/hls/mobilehd_jade.smil?time=*current epoch time in milliseconds*&app=mytv4

The time parameter is required, the app parameter however can be omitted but what the app will also send is a certain request header like so:
Key: t
Value: eeeeb6ee6a25e9ef0fa17e27fe39f7ee0a917d0d761688c83d840b52cfc7fc8e

Supply a valid t request header and the stream link is usable outside the app. Unfortunately I'm not sure how the value's generated so once I get more time, I can research further into that matter.

EDIT: Further examination with the app seems to suggest that the time in milliseconds is encrypted to provide the value for 't'. The encryption method is hidden behind a shared object library so I can't find out how it's getting encrypted without performing disassembly on the file. Judging from the values I've seen over repeated requests, it may seem like two MD5 hashes contatenated with each other.

@renwokuang

This comment has been minimized.

Copy link

commented Nov 15, 2016

有大神还能下载mytvsuper和gotv吗

@newyoyo

This comment has been minimized.

Copy link

commented Jan 4, 2017

Help me~HTTP ERROR 403

@huahua333

This comment has been minimized.

Copy link

commented Feb 24, 2017

super download

@shawn35

This comment has been minimized.

Copy link

commented Apr 27, 2017

yes all links are broken, is there any solution to download from mytvsuper?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.