MasterPuppeteer

Updates fix broken issues.

......@@ -40,8 +40,8 @@ task jarEach << {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.jsoup:jsoup:1.9.2'
compile 'org.json:json:20151123'
compile 'org.jsoup:jsoup:1.10.3'
compile 'org.json:json:20160212'
compile 'org.codehaus.groovy:groovy:2.4.7'
compile project(':puppet')
}
\ No newline at end of file
......
......@@ -56,7 +56,7 @@ public class PasteyPuppet implements InstallablePuppet {
name = "Untitled"
}
} else {
pid = "http://pastebin.com/raw/${pid}"
pid = "https://pastebin.com/raw/${pid}"
}
return new PasteyM3U8Puppet(parent, true, name, pid)
}
......
......@@ -30,7 +30,6 @@ import org.jsoup.nodes.Element
import org.jsoup.select.Elements
import tv.puppetmaster.data.i.*
import java.text.SimpleDateFormat
import java.util.regex.Matcher
class DiscoveryChannelsPuppet implements InstallablePuppet {
......@@ -41,7 +40,7 @@ class DiscoveryChannelsPuppet implements InstallablePuppet {
[
name: "Discovery Channel",
baseUrl: "https://www.discoverygo.com",
page: "/free-preview-on-discovery/",
page: "/shows/",
],
[
name: "Kids",
......@@ -51,17 +50,17 @@ class DiscoveryChannelsPuppet implements InstallablePuppet {
[
name: "Animal Planet",
baseUrl: "https://www.animalplanetgo.com",
page: "/free-preview-on-animal-planet/",
page: "/shows/",
],
[
name: "Science",
baseUrl: "https://www.sciencechannelgo.com",
page: "/free-preview-on-science/",
page: "/shows/",
],
[
name: "Investigation",
baseUrl: "https://www.investigationdiscoverygo.com",
page: "/free-preview-on-id/",
page: "/shows/",
],
]
......@@ -270,9 +269,9 @@ class DiscoveryChannelsPuppet implements InstallablePuppet {
Document document = res.parse()
for (Element item : document.select(".content-item")) {
def String json = item.attr("data-json")
def String json = item.attr("data-show-id")
if (json) {
children.add(new DiscoveryChannelsSourcesPuppet(this, new JSONObject(item.attr("data-json")), mBaseUrl, session))
children.add(new DiscoveryChannelsSourcesPuppet(this, item.attr("data-show-id"), item.attr("data-name"), item.attr("data-show-description"), item.select("img").first().attr("src"), mBaseUrl, session))
}
}
......@@ -288,34 +287,32 @@ class DiscoveryChannelsPuppet implements InstallablePuppet {
def ParentPuppet mParent
def String mName
def String mDescription
def String mPublicationDate
def String mDuration
def String mImageUrl
def JSONObject mItem
def String mShowId
def String mBaseUrl
def String mSession
def List<SourcesPuppet.SubtitleDescription> mSubtitles = new ArrayList<SourcesPuppet.SubtitleDescription>()
DiscoveryChannelsSourcesPuppet(ParentPuppet parent, JSONObject item, String baseUrl, session) {
DiscoveryChannelsSourcesPuppet(ParentPuppet parent, String showId, String name, String description, String imageUrl, String baseUrl, session) {
mParent = parent
mItem = item
mShowId = showId
mName = name
mDescription = description
mImageUrl = imageUrl
mBaseUrl = baseUrl
mSession = session
}
@Override
String getPublicationDate() {
def String dateString = mItem.getJSONArray("networks").getJSONObject(0).getString("airDate")
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")
Date publicationDate = sdf.parse(dateString)
return new SimpleDateFormat("d MMM yyyy").format(publicationDate)
return null
}
@Override
long getDuration() {
return mItem.getInt("duration") * 1000l
return -1
}
@Override
......@@ -335,41 +332,27 @@ class DiscoveryChannelsPuppet implements InstallablePuppet {
@Override
String getName() {
return getCategory() + ": " + mItem.getString("name")
return mName
}
@Override
String getCategory() {
return mItem.getJSONObject("show").getString("name")
return null
}
@Override
String getShortDescription() {
return mItem.getJSONObject("description").getString("standard")
return mDescription
}
@Override
String getImageUrl() {
JSONArray images = mItem.getJSONObject("image").getJSONArray("links")
for (int i = 0; i < images.length(); i++) {
JSONObject j = images.getJSONObject(i)
if (j.getString("rel") == "1x1") {
return j.getString("href").replace("{width}", "300")
}
}
return DiscoveryChannelsPuppet.this.mImageUrl
return mImageUrl
}
@Override
String getBackgroundImageUrl() {
JSONArray images = mItem.getJSONObject("image").getJSONArray("links")
for (int i = 0; i < images.length(); i++) {
JSONObject j = images.getJSONObject(i)
if (j.getString("rel") == "16x9") {
return j.getString("href").replace("{width}", "1024")
}
}
return DiscoveryChannelsPuppet.this.mBackgroundImageUrl
return mBaseUrl.replace("270", "1024").replace("1x1", "original")
}
@Override
......@@ -404,6 +387,8 @@ class DiscoveryChannelsPuppet implements InstallablePuppet {
class DiscoveryChannelsSourceIterator implements SourcesPuppet.SourceIterator {
def static final String SHOW_TEMPLATE = "https://api.discovery.com/v1/streaming/video/"
def ArrayList<SourcesPuppet.SourceDescription> mSources = null
def int currentIndex = 0
......@@ -411,38 +396,28 @@ class DiscoveryChannelsPuppet implements InstallablePuppet {
boolean hasNext() {
if (mSources == null) {
mSources = new ArrayList<SourcesPuppet.SourceDescription>()
JSONArray links = mItem.getJSONArray("links")
String url
for (int i = 0; i < links.length(); i++) {
def JSONObject json = links.getJSONObject(i)
if (json.getString("rel").startsWith("play_")) {
url = json.getString("href")
break
}
String url = SHOW_TEMPLATE + mShowId
url = mBaseUrl + "/api/v1/proxy?url=" + url
def String page = new URL(url).getText(
requestProperties: [
'Cookie': mSession,
'Referer': mBaseUrl,
]
)
def JSONObject json = new JSONObject(page)
def SourcesPuppet.SourceDescription source = new SourcesPuppet.SourceDescription()
source.url = json.getString("streamUrl")
mSources.add(source)
JSONArray captions = json.getJSONArray("captions")
for (int j = 0; j < captions.length(); j++) {
JSONObject caption = captions.getJSONObject(j)
SourcesPuppet.SubtitleDescription subtitle = new SourcesPuppet.SubtitleDescription()
subtitle.url = caption.getString("fileUrl")
subtitle.locale = caption.getString("fileLang")
subtitle.mime = caption.getString("fileType")
mSubtitles.add(subtitle)
}
if (url) {
url = mBaseUrl + "/api/v1/proxy?url=" + url
def String page = new URL(url).getText(
requestProperties: [
'Cookie': 'session=' + mSession,
'Referer': mBaseUrl,
]
)
def JSONObject json = new JSONObject(page)
def SourcesPuppet.SourceDescription source = new SourcesPuppet.SourceDescription()
source.url = json.getString("streamUrl")
mSources.add(source)
JSONArray captions = json.getJSONArray("captions")
for (int j = 0; j < captions.length(); j++) {
JSONObject caption = captions.getJSONObject(j)
SourcesPuppet.SubtitleDescription subtitle = new SourcesPuppet.SubtitleDescription()
subtitle.url = caption.getString("fileUrl")
subtitle.locale = caption.getString("fileLang")
subtitle.mime = caption.getString("fileType")
mSubtitles.add(subtitle)
}}
}
return currentIndex < mSources.size()
}
......
......@@ -41,7 +41,7 @@ public class NASAPuppet implements InstallablePuppet {
NASALiveSourcesPuppet sourcesPuppet = new NASALiveSourcesPuppet()
sourcesPuppet.setParent(this)
sourcesPuppet.setName("Nasa TV")
sourcesPuppet.setUrl("http://nasatv-lh.akamaihd.net/i/NASA_101@319270/master.m3u8")
sourcesPuppet.setUrl("https://nasa-i.akamaihd.net/hls/live/253565/NTV-Public1/master.m3u8")
sourcesPuppet.setImageUrl("https://raw.githubusercontent.com/dersphere/plugin.video.nasa/master/resources/media/public.jpg")
sourcesPuppet.setBackgroundImageUrl("https://raw.githubusercontent.com/dersphere/plugin.video.nasa/master/resources/media/public.jpg")
children.add(sourcesPuppet)
......@@ -49,7 +49,7 @@ public class NASAPuppet implements InstallablePuppet {
sourcesPuppet = new NASALiveSourcesPuppet()
sourcesPuppet.setParent(this)
sourcesPuppet.setName("Media Channel")
sourcesPuppet.setUrl("http://nasatv-lh.akamaihd.net/i/NASA_103@319271/master.m3u8")
sourcesPuppet.setUrl("https://nasa-i.akamaihd.net/hls/live/253566/NTV-Media/master_2000.m3u8")
sourcesPuppet.setImageUrl("https://raw.githubusercontent.com/dersphere/plugin.video.nasa/master/resources/media/media.jpg")
sourcesPuppet.setBackgroundImageUrl("https://raw.githubusercontent.com/dersphere/plugin.video.nasa/master/resources/media/media.jpg")
children.add(sourcesPuppet)
......
......@@ -72,7 +72,10 @@ public class PBSKidsPuppet implements InstallablePuppet {
for (int i = 0; i < items.length(); i++) {
JSONObject item = items.getJSONObject(i)
String name = item.getString("title")
String description = item.getString("description") + " (Ages " + item.getString("age_range") + ")"
String description = item.getString("description")
if (item.has("age_range")) {
description += " (Ages " + item.getString("age_range") + ")"
}
String url = "http://pbskids.org/pbsk/video/api/getVideos/?startindex=1&endindex=200&category=&group=&selectedID=&status=available&player=flash&flash=true&program=" + name.replace(" ","%20").replace("&", "%26")
String image = item.getJSONObject("images").getJSONObject("program-kids-square").getString("url")
children.add(new PBSKidsPuppet(this, url, name, description, false, image))
......