From 165ca35090969f62210d3d690609776f8ea8855e Mon Sep 17 00:00:00 2001 From: Hayk Saakian Date: Sat, 24 Jan 2015 17:36:12 -0800 Subject: [PATCH] Azubu.tv streams support --- .../2.2.1/taskArtifacts/cache.properties.lock | Bin 17 -> 17 bytes .gradle/2.2.1/taskArtifacts/fileHashes.bin | Bin 36243 -> 36355 bytes .gradle/2.2.1/taskArtifacts/fileSnapshots.bin | Bin 376463 -> 387148 bytes .gradle/2.2.1/taskArtifacts/taskArtifacts.bin | Bin 78281 -> 78281 bytes AndroidManifest.xml | 4 +- .../debug/gg/destiny/app/BuildConfig.java | 2 +- src/gg/destiny/app/Business.java | 146 ++++++++++++++---- src/gg/destiny/app/EmoteDownloader.java | 1 + 8 files changed, 119 insertions(+), 34 deletions(-) diff --git a/.gradle/2.2.1/taskArtifacts/cache.properties.lock b/.gradle/2.2.1/taskArtifacts/cache.properties.lock index 9e65140031bf0660a43fafd82220c67b165348f9..f910b934c0b14b39d538cbd191b5dea7fb907775 100644 GIT binary patch literal 17 UcmZQxr{utEQP%gB0StI}0VhiXYXATM literal 17 VcmZQxr{utEQP%gB0Svg-0strH1PK5D diff --git a/.gradle/2.2.1/taskArtifacts/fileHashes.bin b/.gradle/2.2.1/taskArtifacts/fileHashes.bin index 4ee9feecd84ed0cf3b32f4944d6b95487c3798c0..a4549f65f2610c95682bfc5a68efe38f7ab59431 100644 GIT binary patch delta 2678 zcmZ9Odr;I>6vywf3o5#}3JIjJEQ_|XCPG@FjDm^s5EQkN$Ex6im&7LME+B6ZQ4#d$ zDq5}#I%*Q3TTBIsFPc(pNK377G0H}x7*Io*bnBjbZ-3BlX3t^H=YG#Q_x|p^Kj5%k z>3eof^V}q_Sc2V#WMf^9S{JmoPbTcC0+`{^r1`EW~_9nZJ+tvL2a88$>(BZ$qBJz-D$HDRzPfy4zvDw0uF(?!s1<=GBkgmz#=JMD>oG^`QiAVz4mr)ZsO?~I0ng4AM! z_O=4;FVCjUhtAG7mZ9_|s zpL5;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 675 zcmX^4nC0YSmJJTM0)HPevtBhXRWIz|6Q1C;x_hc3qv7QA!nVnZc}|nxeR(CYGa`83 zh63sQ#%B!IkA10rfT6&8{yE#r*@w<3SidgL*Z=$!q+oM;;WkE=PN!Mnn-zIWRKR+;MMDgNg@#8Zyy`Y>*uP#eiKeJ?NLZ2^(q#zt|U zRaY~2cd&ht4_%HVwc%@h1=IdaL4|d5j~gdVo`#U(U;u)%Umm~M9MZm=S0F{GC^G%~ zKGvzJ``<+Jc&JTpP-HZptmW%4eYYy3;O5CwHJAmy?)Tir_dm8|QpgOCFWY=tu&L4a zc#nTRT`l*FF#`j~3m|>~!ptjHZGZPRr}yaTFki03 zJX6CxlP3nrPq)`(RM_0JY$=mqz~)Pny40HF+U}ka>h8Sx5M5sA`m-&QmFjx#Z4I>T zOTP6AMSdj{3)60U&CQl8)s;3MJ$s5pKzIHxbw!0eul^k@yLHc7Z{_BK(>oa_o1LQPTz!jh_-|7P>_OMI-GpWbX>5uB96w6yS|(&k0ird4(r&t=*% z`D2pG 0; if (isLive) { - status = jsno.getString("status"); - } else { - status = channelname + " is offline. Type another channel\'s name below to watch something else."; + return jsno.getString("status"); } - // check hitbox unless twitch was good - if(isLive == false){ - JSONObject hbStatus = getHitboxStatus(url_or_channel_name); - // because hitbox is bad and does not actually 404 from bad channel names - if(hbStatus.length() > 0) { - String liveStatus = hbStatus.getString("media_is_live"); - isLive = "1".equals(liveStatus); - if (isLive) { - status = hbStatus.getString("media_status"); - } + // 2) check hitbox unless twitch was good + jsno = getHitboxStatus(url_or_channel_name); + // because hitbox is bad and does not actually 404 from bad channel names + if(jsno.length() > 0) { + String liveStatus = jsno.getString("media_is_live"); + isLive = "1".equals(liveStatus); + if (isLive) { + return jsno.getString("media_status"); } } + // 3) check azubu + jsno = getAzubuStatus(url_or_channel_name); + isLive = false; + if (jsno.length() > 0){ + isLive = true; + return jsno.getString("title"); + } + return channelname + " is offline. Type another channel\'s name below to watch something else."; } } catch (JSONException e) { @@ -225,26 +232,35 @@ protected HashMap doInBackground(String... channels) { String auth = getTwitchAuth(channel); newQualities = getTwitchQualities(channel, auth); + if(newQualities.size() > 0){ + return newQualities; + } + // check hitbox if twitch doesn't have anything - if(newQualities.size() == 0){ - try { - // unfortunately, getting the list of qualities - // does not truthfully tell us if the stream is live - // so we have to GET the status API too - // TODO: cache this maybe - JSONObject hbStatus = getHitboxStatus(channel); - - if(hbStatus.length() > 0) { - String liveStatus = hbStatus.getString("media_is_live"); - if ("1".equals(liveStatus)) { - String streams_url = String.format("http://api.hitbox.tv/player/hls/%s.m3u8", channel); - newQualities = parseQualitiesFromURL(streams_url); - } + try { + // unfortunately, getting the list of qualities + // does not truthfully tell us if the stream is live + // so we have to GET the status API too + // TODO: cache this maybe + JSONObject hbStatus = getHitboxStatus(channel); + + if(hbStatus.length() > 0) { + String liveStatus = hbStatus.getString("media_is_live"); + if ("1".equals(liveStatus)) { + String streams_url = String.format("http://api.hitbox.tv/player/hls/%s.m3u8", channel); + newQualities = parseQualitiesFromURL(streams_url); } - } catch (JSONException e) { - e.printStackTrace(); } + } catch (JSONException e) { + e.printStackTrace(); + } + + if(newQualities.size() > 0){ + return newQualities; } + + // check azubu if hitbox doesn't have anything + newQualities = getAzubuQualities(channel); } //String readURL = HttpGet(url); @@ -348,6 +364,66 @@ public static HashMap getTwitchQualities(String channel, String auth) { } return mQualities; } + public static HashMap getAzubuQualities(String channel) { + try { + JSONObject status = getAzubuStatus(channel); + if (status.length() > 0) { + return getAzubuQualities(channel, status); + } + } catch (JSONException e) { + e.printStackTrace(); + } + return new HashMap(); + } + + // this seems like a constant, but might not be + public static String AZUBU_PUB_ID = "3361910549001"; + + public static HashMap getAzubuQualities(String channel, JSONObject status) { + HashMap mQualities = new HashMap(); + try { + + String keyContainingHtml = HttpGet("http://www.azubu.tv/"+channel); + // found here: + // https://github.com/chrippa/livestreamer/blob/da58e4a05405e0e23bbefb1f9d83a6dd88d1d454/src/livestreamer/plugins/azubutv.py#L135 + Pattern pattern = Pattern.compile("name=\"playerKey\" value=\"(.+)\""); + Matcher matcher = pattern.matcher(keyContainingHtml); + matcher.find(); + + String playerKey = matcher.group(1); + String refId = "video" + status.getString("id") + "CH" + channel.replace("_", ""); + + String streamApiUrl = "http://c.brightcove.com/services/json/player/media/?command=find_media_by_reference_id" + + "&playerKey=" + playerKey + + "&refId=" + refId + + "&pubId=" + AZUBU_PUB_ID; + + String sStreamApiData = HttpGet(streamApiUrl); + JSONObject json = new JSONObject(sStreamApiData); + String qualitiesURL = json.getString("FLVFullLengthURL"); + if (!qualitiesURL.endsWith("m3u8")){ + qualitiesURL = json.getJSONArray("IOSRenditions").getJSONObject(0).getString("defaultURL"); + } + + // their qualities are not prefixed by a proper url + mQualities = parseQualitiesFromURL(qualitiesURL, refId); + + List list = new ArrayList(); + list.addAll(mQualities.keySet()); + + String urlprefix = qualitiesURL.replace(refId+".m3u8", ""); + + for (int i = 0; i < list.size(); i++) { + String mq = list.get(i); + String mqpath = (String)mQualities.get(mq); + mQualities.put(mq, urlprefix + mqpath); + } + } catch (JSONException e) { + e.printStackTrace(); + } + + return mQualities; + } public static JSONObject getAzubuStatus(String channel) throws JSONException{ String hburl = String.format("http://www.azubu.tv/api/video/active-stream/%s", channel); @@ -359,6 +435,8 @@ public static JSONObject getAzubuStatus(String channel) throws JSONException{ return json.getJSONArray("data").getJSONObject(0); } + + public static JSONObject getHitboxStatus(String channel) throws JSONException{ JSONObject channelStatus = new JSONObject(); @@ -409,6 +487,9 @@ public static String getTwitchAuth(String channel) { } public static HashMap parseQualitiesFromURL(String url) { + return parseQualitiesFromURL(url, "http"); + } + public static HashMap parseQualitiesFromURL(String url, String urlPrefix) { HashMap mQualities = new HashMap(); String qualityOptions = HttpGet(url); // Log.d("Quality Response", qualityOptions); @@ -455,10 +536,13 @@ public static HashMap parseQualitiesFromURL(String url) { if (mQualities.containsKey(lastquality) && info.containsKey("BANDWIDTH")) { int bw = Integer.parseInt(info.get("BANDWIDTH")); lastquality = lastquality + "@" + Integer.toString(bw / 1000) + "kbps"; + }else if(lastquality.contains("BANDWIDTH=")){ + int bw = Integer.parseInt(info.get("BANDWIDTH")); + lastquality = Integer.toString(bw / 1000) + "kbps"; } Log.d("found quality", lastquality); - } else if (line.startsWith("http") && lastquality != null) { + } else if (line.startsWith(urlPrefix) && lastquality != null) { // we need to pull the quality name out of the URL for hitbox m3u8 streams if(line.contains("hitbox.tv/hls/") && line.contains("/index.m3u8")){ lastquality = line.substring(line.indexOf("hitbox.tv/hls/") + 1, line.indexOf("/index.m3u8")); diff --git a/src/gg/destiny/app/EmoteDownloader.java b/src/gg/destiny/app/EmoteDownloader.java index 9349347..f1a8cf1 100644 --- a/src/gg/destiny/app/EmoteDownloader.java +++ b/src/gg/destiny/app/EmoteDownloader.java @@ -74,6 +74,7 @@ public class EmoteDownloader extends AsyncTask { protected String[] doInBackground(String... notes) { String[] emotes = EMOTICON_LIST; //if(false){ + if (notes.length > 0) { note = notes[0];