Last active
August 5, 2019 13:10
-
-
Save seventhmoon/9ac378c006d6c9a0b944 to your computer and use it in GitHub Desktop.
Get M3U8 Playlist from TVB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Help me~HTTP ERROR 403
super download
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
有大神还能下载mytvsuper和gotv吗