MasterPuppeteer

Fix for API change

......@@ -23,6 +23,7 @@ package tv.puppetmaster.usa
import org.json.JSONArray
import org.json.JSONObject
import org.jsoup.Jsoup
import tv.puppetmaster.data.i.*
import tv.puppetmaster.data.i.Puppet.PuppetIterator
import tv.puppetmaster.data.i.SourcesPuppet.SourceDescription
......@@ -224,7 +225,7 @@ public class RedBullTVPuppet implements InstallablePuppet {
JSONObject json = new JSONObject(page)
if (mUrl == "https://api.redbull.tv/v1/") {
RedBullTVIterator videos = new RedBullTVIterator(mParent, json.get("videos").toString())
RedBullTVIterator videos = new RedBullTVIterator(mParent, json.get("videos").toString() + "/clips")
while (videos.hasNext()) {
Puppet p = videos.next()
sourcesItems.put(new JSONArray())
......@@ -292,7 +293,7 @@ public class RedBullTVPuppet implements InstallablePuppet {
sourcesItems.put(new JSONArray()) // Dummy, TODO: make this more efficient by excluding sourcesItems/categoryItems with count
mPuppets.add(item)
}
["episodes", "clips", "films", "event_streams", "events", "usa", "featured_shows"].each { videoType ->
["episodes", "clips", "films", "event_streams", "events"/*, "usa"*/, "featured_shows"].each { videoType ->
mPuppets.add(new RedBullTVPuppet(
mParent,
videoType.replace("_", " ").capitalize(),
......@@ -353,11 +354,29 @@ public class RedBullTVPuppet implements InstallablePuppet {
if (item.has("duration")) {
mDuration = convertDuration(item.get("duration").toString())
}
mImageUrl = ((JSONObject) ((JSONObject) item.get("images")).get("landscape")).get("uri").toString()
try {
mImageUrl = ((JSONObject) ((JSONObject) item.get("images")).get("landscape")).get("uri").toString()
} catch (ex) {
try {
mImageUrl = ((JSONObject) ((JSONObject) item.get("images")).get("background")).get("uri").toString()
} catch (ignored) {}
}
if (mImageUrl == null) {
mImageUrl = mParent.getImageUrl()
} else if (mImageUrl.count("http") > 1) {
mImageUrl = Jsoup.parse(mImageUrl.substring(mImageUrl.indexOf("http", 1)))
}
try {
mBackgroundImageUrl = ((JSONObject) ((JSONObject) item.get("images")).get("background")).get("uri").toString()
} catch (ignored) {
mBackgroundImageUrl = ((JSONObject) ((JSONObject) item.get("images")).get("landscape")).get("uri").toString()
} catch (ex) {
try {
mBackgroundImageUrl = ((JSONObject) ((JSONObject) item.get("images")).get("landscape")).get("uri").toString()
} catch (ignored) {}
}
if (mBackgroundImageUrl == null) {
mBackgroundImageUrl = mParent.getBackgroundImageUrl()
} else if (mBackgroundImageUrl.count("http") > 1) {
mBackgroundImageUrl = Jsoup.parse(mBackgroundImageUrl.substring(mBackgroundImageUrl.indexOf("http", 1)))
}
if (item.has("closed_captions")) {
......