MasterPuppeteer

Updates fix broken issues.

...@@ -40,8 +40,8 @@ task jarEach << { ...@@ -40,8 +40,8 @@ task jarEach << {
40 40
41 dependencies { 41 dependencies {
42 compile fileTree(dir: 'libs', include: ['*.jar']) 42 compile fileTree(dir: 'libs', include: ['*.jar'])
43 - compile 'org.jsoup:jsoup:1.9.2' 43 + compile 'org.jsoup:jsoup:1.10.3'
44 - compile 'org.json:json:20151123' 44 + compile 'org.json:json:20160212'
45 compile 'org.codehaus.groovy:groovy:2.4.7' 45 compile 'org.codehaus.groovy:groovy:2.4.7'
46 compile project(':puppet') 46 compile project(':puppet')
47 } 47 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -56,7 +56,7 @@ public class PasteyPuppet implements InstallablePuppet { ...@@ -56,7 +56,7 @@ public class PasteyPuppet implements InstallablePuppet {
56 name = "Untitled" 56 name = "Untitled"
57 } 57 }
58 } else { 58 } else {
59 - pid = "http://pastebin.com/raw/${pid}" 59 + pid = "https://pastebin.com/raw/${pid}"
60 } 60 }
61 return new PasteyM3U8Puppet(parent, true, name, pid) 61 return new PasteyM3U8Puppet(parent, true, name, pid)
62 } 62 }
......
...@@ -30,7 +30,6 @@ import org.jsoup.nodes.Element ...@@ -30,7 +30,6 @@ import org.jsoup.nodes.Element
30 import org.jsoup.select.Elements 30 import org.jsoup.select.Elements
31 import tv.puppetmaster.data.i.* 31 import tv.puppetmaster.data.i.*
32 32
33 -import java.text.SimpleDateFormat
34 import java.util.regex.Matcher 33 import java.util.regex.Matcher
35 34
36 class DiscoveryChannelsPuppet implements InstallablePuppet { 35 class DiscoveryChannelsPuppet implements InstallablePuppet {
...@@ -41,7 +40,7 @@ class DiscoveryChannelsPuppet implements InstallablePuppet { ...@@ -41,7 +40,7 @@ class DiscoveryChannelsPuppet implements InstallablePuppet {
41 [ 40 [
42 name: "Discovery Channel", 41 name: "Discovery Channel",
43 baseUrl: "https://www.discoverygo.com", 42 baseUrl: "https://www.discoverygo.com",
44 - page: "/free-preview-on-discovery/", 43 + page: "/shows/",
45 ], 44 ],
46 [ 45 [
47 name: "Kids", 46 name: "Kids",
...@@ -51,17 +50,17 @@ class DiscoveryChannelsPuppet implements InstallablePuppet { ...@@ -51,17 +50,17 @@ class DiscoveryChannelsPuppet implements InstallablePuppet {
51 [ 50 [
52 name: "Animal Planet", 51 name: "Animal Planet",
53 baseUrl: "https://www.animalplanetgo.com", 52 baseUrl: "https://www.animalplanetgo.com",
54 - page: "/free-preview-on-animal-planet/", 53 + page: "/shows/",
55 ], 54 ],
56 [ 55 [
57 name: "Science", 56 name: "Science",
58 baseUrl: "https://www.sciencechannelgo.com", 57 baseUrl: "https://www.sciencechannelgo.com",
59 - page: "/free-preview-on-science/", 58 + page: "/shows/",
60 ], 59 ],
61 [ 60 [
62 name: "Investigation", 61 name: "Investigation",
63 baseUrl: "https://www.investigationdiscoverygo.com", 62 baseUrl: "https://www.investigationdiscoverygo.com",
64 - page: "/free-preview-on-id/", 63 + page: "/shows/",
65 ], 64 ],
66 ] 65 ]
67 66
...@@ -270,9 +269,9 @@ class DiscoveryChannelsPuppet implements InstallablePuppet { ...@@ -270,9 +269,9 @@ class DiscoveryChannelsPuppet implements InstallablePuppet {
270 Document document = res.parse() 269 Document document = res.parse()
271 270
272 for (Element item : document.select(".content-item")) { 271 for (Element item : document.select(".content-item")) {
273 - def String json = item.attr("data-json") 272 + def String json = item.attr("data-show-id")
274 if (json) { 273 if (json) {
275 - children.add(new DiscoveryChannelsSourcesPuppet(this, new JSONObject(item.attr("data-json")), mBaseUrl, session)) 274 + 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))
276 } 275 }
277 } 276 }
278 277
...@@ -288,34 +287,32 @@ class DiscoveryChannelsPuppet implements InstallablePuppet { ...@@ -288,34 +287,32 @@ class DiscoveryChannelsPuppet implements InstallablePuppet {
288 def ParentPuppet mParent 287 def ParentPuppet mParent
289 def String mName 288 def String mName
290 def String mDescription 289 def String mDescription
291 - def String mPublicationDate
292 - def String mDuration
293 def String mImageUrl 290 def String mImageUrl
294 291
295 - def JSONObject mItem 292 + def String mShowId
296 def String mBaseUrl 293 def String mBaseUrl
297 def String mSession 294 def String mSession
298 295
299 def List<SourcesPuppet.SubtitleDescription> mSubtitles = new ArrayList<SourcesPuppet.SubtitleDescription>() 296 def List<SourcesPuppet.SubtitleDescription> mSubtitles = new ArrayList<SourcesPuppet.SubtitleDescription>()
300 297
301 - DiscoveryChannelsSourcesPuppet(ParentPuppet parent, JSONObject item, String baseUrl, session) { 298 + DiscoveryChannelsSourcesPuppet(ParentPuppet parent, String showId, String name, String description, String imageUrl, String baseUrl, session) {
302 mParent = parent 299 mParent = parent
303 - mItem = item 300 + mShowId = showId
301 + mName = name
302 + mDescription = description
303 + mImageUrl = imageUrl
304 mBaseUrl = baseUrl 304 mBaseUrl = baseUrl
305 mSession = session 305 mSession = session
306 } 306 }
307 307
308 @Override 308 @Override
309 String getPublicationDate() { 309 String getPublicationDate() {
310 - def String dateString = mItem.getJSONArray("networks").getJSONObject(0).getString("airDate") 310 + return null
311 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")
312 - Date publicationDate = sdf.parse(dateString)
313 - return new SimpleDateFormat("d MMM yyyy").format(publicationDate)
314 } 311 }
315 312
316 @Override 313 @Override
317 long getDuration() { 314 long getDuration() {
318 - return mItem.getInt("duration") * 1000l 315 + return -1
319 } 316 }
320 317
321 @Override 318 @Override
...@@ -335,41 +332,27 @@ class DiscoveryChannelsPuppet implements InstallablePuppet { ...@@ -335,41 +332,27 @@ class DiscoveryChannelsPuppet implements InstallablePuppet {
335 332
336 @Override 333 @Override
337 String getName() { 334 String getName() {
338 - return getCategory() + ": " + mItem.getString("name") 335 + return mName
339 } 336 }
340 337
341 @Override 338 @Override
342 String getCategory() { 339 String getCategory() {
343 - return mItem.getJSONObject("show").getString("name") 340 + return null
344 } 341 }
345 342
346 @Override 343 @Override
347 String getShortDescription() { 344 String getShortDescription() {
348 - return mItem.getJSONObject("description").getString("standard") 345 + return mDescription
349 } 346 }
350 347
351 @Override 348 @Override
352 String getImageUrl() { 349 String getImageUrl() {
353 - JSONArray images = mItem.getJSONObject("image").getJSONArray("links") 350 + return mImageUrl
354 - for (int i = 0; i < images.length(); i++) {
355 - JSONObject j = images.getJSONObject(i)
356 - if (j.getString("rel") == "1x1") {
357 - return j.getString("href").replace("{width}", "300")
358 - }
359 - }
360 - return DiscoveryChannelsPuppet.this.mImageUrl
361 } 351 }
362 352
363 @Override 353 @Override
364 String getBackgroundImageUrl() { 354 String getBackgroundImageUrl() {
365 - JSONArray images = mItem.getJSONObject("image").getJSONArray("links") 355 + return mBaseUrl.replace("270", "1024").replace("1x1", "original")
366 - for (int i = 0; i < images.length(); i++) {
367 - JSONObject j = images.getJSONObject(i)
368 - if (j.getString("rel") == "16x9") {
369 - return j.getString("href").replace("{width}", "1024")
370 - }
371 - }
372 - return DiscoveryChannelsPuppet.this.mBackgroundImageUrl
373 } 356 }
374 357
375 @Override 358 @Override
...@@ -404,6 +387,8 @@ class DiscoveryChannelsPuppet implements InstallablePuppet { ...@@ -404,6 +387,8 @@ class DiscoveryChannelsPuppet implements InstallablePuppet {
404 387
405 class DiscoveryChannelsSourceIterator implements SourcesPuppet.SourceIterator { 388 class DiscoveryChannelsSourceIterator implements SourcesPuppet.SourceIterator {
406 389
390 + def static final String SHOW_TEMPLATE = "https://api.discovery.com/v1/streaming/video/"
391 +
407 def ArrayList<SourcesPuppet.SourceDescription> mSources = null 392 def ArrayList<SourcesPuppet.SourceDescription> mSources = null
408 def int currentIndex = 0 393 def int currentIndex = 0
409 394
...@@ -411,38 +396,28 @@ class DiscoveryChannelsPuppet implements InstallablePuppet { ...@@ -411,38 +396,28 @@ class DiscoveryChannelsPuppet implements InstallablePuppet {
411 boolean hasNext() { 396 boolean hasNext() {
412 if (mSources == null) { 397 if (mSources == null) {
413 mSources = new ArrayList<SourcesPuppet.SourceDescription>() 398 mSources = new ArrayList<SourcesPuppet.SourceDescription>()
414 - 399 + String url = SHOW_TEMPLATE + mShowId
415 - JSONArray links = mItem.getJSONArray("links") 400 + url = mBaseUrl + "/api/v1/proxy?url=" + url
416 - String url 401 + def String page = new URL(url).getText(
417 - for (int i = 0; i < links.length(); i++) { 402 + requestProperties: [
418 - def JSONObject json = links.getJSONObject(i) 403 + 'Cookie': mSession,
419 - if (json.getString("rel").startsWith("play_")) { 404 + 'Referer': mBaseUrl,
420 - url = json.getString("href") 405 + ]
421 - break 406 + )
422 - } 407 + def JSONObject json = new JSONObject(page)
408 + def SourcesPuppet.SourceDescription source = new SourcesPuppet.SourceDescription()
409 + source.url = json.getString("streamUrl")
410 + mSources.add(source)
411 + JSONArray captions = json.getJSONArray("captions")
412 + for (int j = 0; j < captions.length(); j++) {
413 + JSONObject caption = captions.getJSONObject(j)
414 +
415 + SourcesPuppet.SubtitleDescription subtitle = new SourcesPuppet.SubtitleDescription()
416 + subtitle.url = caption.getString("fileUrl")
417 + subtitle.locale = caption.getString("fileLang")
418 + subtitle.mime = caption.getString("fileType")
419 + mSubtitles.add(subtitle)
423 } 420 }
424 - if (url) {
425 - url = mBaseUrl + "/api/v1/proxy?url=" + url
426 - def String page = new URL(url).getText(
427 - requestProperties: [
428 - 'Cookie': 'session=' + mSession,
429 - 'Referer': mBaseUrl,
430 - ]
431 - )
432 - def JSONObject json = new JSONObject(page)
433 - def SourcesPuppet.SourceDescription source = new SourcesPuppet.SourceDescription()
434 - source.url = json.getString("streamUrl")
435 - mSources.add(source)
436 - JSONArray captions = json.getJSONArray("captions")
437 - for (int j = 0; j < captions.length(); j++) {
438 - JSONObject caption = captions.getJSONObject(j)
439 -
440 - SourcesPuppet.SubtitleDescription subtitle = new SourcesPuppet.SubtitleDescription()
441 - subtitle.url = caption.getString("fileUrl")
442 - subtitle.locale = caption.getString("fileLang")
443 - subtitle.mime = caption.getString("fileType")
444 - mSubtitles.add(subtitle)
445 - }}
446 } 421 }
447 return currentIndex < mSources.size() 422 return currentIndex < mSources.size()
448 } 423 }
......
...@@ -41,7 +41,7 @@ public class NASAPuppet implements InstallablePuppet { ...@@ -41,7 +41,7 @@ public class NASAPuppet implements InstallablePuppet {
41 NASALiveSourcesPuppet sourcesPuppet = new NASALiveSourcesPuppet() 41 NASALiveSourcesPuppet sourcesPuppet = new NASALiveSourcesPuppet()
42 sourcesPuppet.setParent(this) 42 sourcesPuppet.setParent(this)
43 sourcesPuppet.setName("Nasa TV") 43 sourcesPuppet.setName("Nasa TV")
44 - sourcesPuppet.setUrl("http://nasatv-lh.akamaihd.net/i/NASA_101@319270/master.m3u8") 44 + sourcesPuppet.setUrl("https://nasa-i.akamaihd.net/hls/live/253565/NTV-Public1/master.m3u8")
45 sourcesPuppet.setImageUrl("https://raw.githubusercontent.com/dersphere/plugin.video.nasa/master/resources/media/public.jpg") 45 sourcesPuppet.setImageUrl("https://raw.githubusercontent.com/dersphere/plugin.video.nasa/master/resources/media/public.jpg")
46 sourcesPuppet.setBackgroundImageUrl("https://raw.githubusercontent.com/dersphere/plugin.video.nasa/master/resources/media/public.jpg") 46 sourcesPuppet.setBackgroundImageUrl("https://raw.githubusercontent.com/dersphere/plugin.video.nasa/master/resources/media/public.jpg")
47 children.add(sourcesPuppet) 47 children.add(sourcesPuppet)
...@@ -49,7 +49,7 @@ public class NASAPuppet implements InstallablePuppet { ...@@ -49,7 +49,7 @@ public class NASAPuppet implements InstallablePuppet {
49 sourcesPuppet = new NASALiveSourcesPuppet() 49 sourcesPuppet = new NASALiveSourcesPuppet()
50 sourcesPuppet.setParent(this) 50 sourcesPuppet.setParent(this)
51 sourcesPuppet.setName("Media Channel") 51 sourcesPuppet.setName("Media Channel")
52 - sourcesPuppet.setUrl("http://nasatv-lh.akamaihd.net/i/NASA_103@319271/master.m3u8") 52 + sourcesPuppet.setUrl("https://nasa-i.akamaihd.net/hls/live/253566/NTV-Media/master_2000.m3u8")
53 sourcesPuppet.setImageUrl("https://raw.githubusercontent.com/dersphere/plugin.video.nasa/master/resources/media/media.jpg") 53 sourcesPuppet.setImageUrl("https://raw.githubusercontent.com/dersphere/plugin.video.nasa/master/resources/media/media.jpg")
54 sourcesPuppet.setBackgroundImageUrl("https://raw.githubusercontent.com/dersphere/plugin.video.nasa/master/resources/media/media.jpg") 54 sourcesPuppet.setBackgroundImageUrl("https://raw.githubusercontent.com/dersphere/plugin.video.nasa/master/resources/media/media.jpg")
55 children.add(sourcesPuppet) 55 children.add(sourcesPuppet)
......
...@@ -72,7 +72,10 @@ public class PBSKidsPuppet implements InstallablePuppet { ...@@ -72,7 +72,10 @@ public class PBSKidsPuppet implements InstallablePuppet {
72 for (int i = 0; i < items.length(); i++) { 72 for (int i = 0; i < items.length(); i++) {
73 JSONObject item = items.getJSONObject(i) 73 JSONObject item = items.getJSONObject(i)
74 String name = item.getString("title") 74 String name = item.getString("title")
75 - String description = item.getString("description") + " (Ages " + item.getString("age_range") + ")" 75 + String description = item.getString("description")
76 + if (item.has("age_range")) {
77 + description += " (Ages " + item.getString("age_range") + ")"
78 + }
76 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") 79 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")
77 String image = item.getJSONObject("images").getJSONObject("program-kids-square").getString("url") 80 String image = item.getJSONObject("images").getJSONObject("program-kids-square").getString("url")
78 children.add(new PBSKidsPuppet(this, url, name, description, false, image)) 81 children.add(new PBSKidsPuppet(this, url, name, description, false, image))
......