diff --git a/Makefile b/Makefile deleted file mode 100644 index a33f6d1..0000000 --- a/Makefile +++ /dev/null @@ -1,16 +0,0 @@ - -PLUGINS= \ - xxxstream.zip \ - di.zip \ - icecast.zip \ - somafm.zip \ - rad.io.zip \ - lubetube.zip \ - redtube.zip - -%.zip: - @echo "Bundle plugin '$*'" - @rm -f ./plugins/$*.zip - @cd $*; zip -r9 ../plugins/$*.zip * -x *.js\~ > /dev/null; cd .. - -all: ${PLUGINS} diff --git a/animetoon/animetoon.js b/animetoon/animetoon.js new file mode 100644 index 0000000..8f6ca2f --- /dev/null +++ b/animetoon/animetoon.js @@ -0,0 +1,258 @@ +/** + * Animetoon plugin for Showtime Media Center + * + * Copyright (C) 2014 fdm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +(function(plugin) { + var PLUGIN_PREFIX = "animetoon:"; + var SITE_URL = "http://animetoon.tv"; + var service = plugin.createService("Animetoon", PLUGIN_PREFIX + "start", "video", true, plugin.path + "animetoon.png"); + + function getBetween(str0, str1, str2) { + var tmp = str0.substring(str0.indexOf(str1) + str1.length, str0.length); + return tmp.substring(0, tmp.indexOf(str2)); + } + + plugin.addURI(PLUGIN_PREFIX + "start", function(page) { + page.type = "directory"; + page.metadata.title = 'Animetoon'; + page.appendItem(PLUGIN_PREFIX + "byletter:" + showtime.JSONEncode({ + type: "Dubbed Anime", + postfix: "/dubbed-anime" + }), "directory", { + title: "Dubbed Anime" + }); + page.appendItem(PLUGIN_PREFIX + "byletter:" + showtime.JSONEncode({ + type: "Cartoons", + postfix: "/cartoon" + }), "directory", { + title: "Cartoon List" + }); + page.appendItem(PLUGIN_PREFIX + "byletter:" + showtime.JSONEncode({ + type: "Movies", + postfix: "/movies" + }), "directory", { + title: "Movie List" + }); + page.loading = false; + }); + + plugin.addURI(PLUGIN_PREFIX + "byletter:(.*)", function(page, vars) { + var type = showtime.JSONDecode(vars).type; + var postfix = showtime.JSONDecode(vars).postfix; + page.type = "directory"; + page.metadata.title = type + ' By Letter'; + page.appendItem(PLUGIN_PREFIX + "getlisting:" + showtime.JSONEncode({ + type: type, + postfix: postfix, + letter: "#" + }), "directory", { + title: "#" + }); + for (var i = 0; i < 26; i++) { + page.appendItem(PLUGIN_PREFIX + "getlisting:" + showtime.JSONEncode({ + type: type, + postfix: postfix, + letter: String.fromCharCode(i + 65) + }), "directory", { + title: String.fromCharCode(i + 65) + }); + } + page.loading = false; + }); + + plugin.addURI(PLUGIN_PREFIX + "getlisting:(.*)", function(page, vars) { + var type = showtime.JSONDecode(vars).type; + var postfix = showtime.JSONDecode(vars).postfix; + var letter = showtime.JSONDecode(vars).letter; + var prefix = "getepisodes:" + if (type == "Movies") { + prefix == "getmovies:" + } + page.type = "directory"; + page.metadata.title = type + " - " + letter; + showtime.trace(SITE_URL + postfix); + var html = showtime.httpGet(SITE_URL + postfix).toString(); + var capture = getBetween(html, "

" + letter + "

", ""); + var segments = capture.split("") + var left = new Array(); + var right = new Array(); + for (var i = 1; i < segments.length; i++) { + var parts = segments[i].split("") + left[left.length] = [getBetween(parts[1], ">", "<"), getBetween(parts[1], "href=\"", "\"")]; + if (parts[2].indexOf("href=\"") != -1) { + right[right.length] = [getBetween(parts[2], ">", "<"), getBetween(parts[2], "href=\"", "\"")]; + } + } + for (var y = 0; y < left.length; y++) { + page.appendItem(PLUGIN_PREFIX + prefix + showtime.JSONEncode({ + title: left[y][0], + link: left[y][1] + }), "directory", { + title: left[y][0] + }); + } + for (var z = 0; z < right.length; z++) { + page.appendItem(PLUGIN_PREFIX + prefix + showtime.JSONEncode({ + title: right[z][0], + link: right[z][1] + }), "directory", { + title: right[z][0] + }); + } + page.loading = false; + }); + + plugin.addURI(PLUGIN_PREFIX + "getepisodes:(.*)", function(page, vars) { + var title = showtime.JSONDecode(vars).title; + var link = showtime.JSONDecode(vars).link; + page.type = "directory"; + page.metadata.title = title + " Episodes"; + showtime.trace(link); + var html = showtime.httpGet(link).toString(); + while (true) { + var capture = getBetween(html, "
", "
"); + var segments = capture.split("
  • "); + for (var i = 1; i < segments.length; i++) { + var eptitle = getBetween(segments[i], ">", "<"); + var eplink = getBetween(segments[i], "href=\"", "\""); + page.appendItem(PLUGIN_PREFIX + "gethosts:" + showtime.JSONEncode({ + title: eptitle, + link: eplink, + playlist: "", + round: "0" + }), "directory", { + title: eptitle + }); + } + if (html.indexOf("