示例#1
0
def GetPartyYears(id):
  result = GetJsonQuery("partyyears&id_party=" + id)
  dir = MediaContainer("art-default.png", title1="demoscene.tv", title2=GetJsonQueryTitle("partyyears&id_party=" + id))
  dir.AppendItem(DirectoryItem("all_years", "all years", _R("icon-default.png"), "all years"))
  for item in result["items"]:
    dir.AppendItem(DirectoryItem(item, item, _R("icon-default.png"), item))
  return dir
示例#2
0
def getTivoNames():
    dir = MediaContainer('art-default.jpg', title1="TiVo")

    myMAC = Prefs.Get("MAC")
    if myMAC == None:
        myMAC = ""
    if (len(myMAC) == 10):
        p1 = Popen(["mDNS", "-B", "_tivo-videos._tcp", "local"], stdout=PIPE)
        p2 = Popen(["colrm", "1", "74"], stdin=p1.stdout, stdout=PIPE)
        p3 = Popen(["grep", "-v", "Instance Name"],
                   stdin=p2.stdout,
                   stdout=PIPE)
        p4 = Popen(["sort"], stdin=p3.stdout, stdout=PIPE)
        p5 = Popen(["uniq"], stdin=p4.stdout, stdout=PIPE)
        sleep(2)
        kill(p1.pid, SIGTERM)
        tivolist = p5.communicate()[0]

        for line in tivolist.split('\n'):
            curtivo = line.lstrip().rstrip()
            if len(curtivo) > 0:
                Log.Add("Adding %s" % curtivo)
                dir.AppendItem(
                    DirectoryItem(
                        TIVO_PLUGIN_PREFIX + "/" + TIVO_BY_NAME + "/" +
                        curtivo, curtivo, ""))

    dir.AppendItem(
        SearchDirectoryItem(TIVO_PLUGIN_PREFIX + "/" + TIVO_PREFS + "/MAC",
                            "Set your Media Access Key",
                            "Set your Media Access Key  [" + myMAC + "] ", ""))
    return dir.ToXML()
示例#3
0
def RecentVideos():
    dir = MediaContainer(FILE_DEFAULT_ART,
                         title1=TEXT_IGN,
                         title2=TEXT_RECENT_VIDEOS)

    first = True
    for row in LoadUrl(URL_ALL, CACHE_INT_RECENT).xpath(XPATH_RECENT_VIDEOS):
        if first:  # Need to skip header row (Hey IGN, use a thead like the rest of us!)
            first = False
            continue

        url = row.find("td//a").get("href")
        name = row.find("td//a").text.strip()

        # Need to label category
        icon = row.find("td/img").get(
            "src")  # Again, IGN, how about some alt text?
        begin = icon.find("icon_") + 5
        end = icon.find(".gif")
        label = icon[begin:end]
        if label == "video":
            nameLabeled = name
        else:
            nameLabeled = "[" + _L(label) + "] " + name

        dir.AppendItem(DirectoryItem(_E(url) + "||" + name, nameLabeled, None))

    return dir.ToXML()
示例#4
0
def GetFeedDirectory(feed):
  feed = GetJsonQuery(feed, DTV_FEED_LENGTH)
  dir = MediaContainer("art-default.png", title1="demoscene.tv", title2=re.sub(TITLE_CUT_PHRASE, "", GetValue("title", feed)))
  
  for item in feed["items"]:
    try:
      # mandatory data
      title = re.sub(TITLE_CUT_PHRASE, "", GetValue("title", item))
      videoUrl = GetValue("videofile", item)
      thumbUrl = GetValue("screenshot", item)
      desc = "n/a";
      
      # optional metadata
      creator = GetValue("creator", item)
      category = GetValue("category", item)
      type = GetValue("type", item)
      event = GetValue("event", item)
      year_event = GetValue("year_event", item)
      released_date = GetValue("released_date", item)
      added_date = GetValue("added_date", item)
      viewed = GetValue("viewed", item)
      
      # build description fom metadata
      desc = "Demogroup:\t"+ creator +"\n\nParty/Event:\t"+ event +" "+ year_event +"\n\nType:\t"+ type +"\nPlatform:\t"+ category +"\nReleased:\t"+ released_date +"\n\nAdded to DTV:\t"+ added_date +"\nViewed on DTV:\t"+ viewed
        
      dir.AppendItem(VideoItem(videoUrl, title, desc, "", thumbUrl))
    
    except:
      Log.Add("Failed to load entry!")
      
  return dir
示例#5
0
def SimpleHomePagePlaylist(query, title):
    dir = MediaContainer(FILE_DEFAULT_ART, title1=TEXT_IGN, title2=title)

    for video in HomePageXml().xpath(query):
        videoPage = video.get("href")
        thumbUrl = video.find("img").get("src")
        dir.AppendItem(CreateVideoItemFromPage(videoPage, thumbUrl))

    return dir.ToXML()
示例#6
0
def GetList(listname):
  result = GetJsonQuery(listname)
  list = result["items"]
  
  dir = MediaContainer("art-default.png", title1="demoscene.tv", title2=GetJsonQueryTitle(listname))
  for id, name in list:
    Debug("item: ", id +"->" + name)
    dir.AppendItem(DirectoryItem(id, name, _R("icon-default.png"), name))
  
  return dir
示例#7
0
def populateFromFeed(url, secondTitle=None, firstTitle=None):
    if not firstTitle:
        firstTitle = "Channels"

    dir = MediaContainer('art-default.jpg', None, firstTitle, secondTitle)
    dir.SetViewGroup("InfoList")
    if USE_CACHE == True:
        feed = RSS.Parse(HTTP.GetCached(url, CACHE_INTERVAL))
    else:
        feed = RSS.Parse(url)

    added = 0
    for e in feed["items"]:
        try:
            id = e.enclosures[0]["href"]
            media_type = e.enclosures[0]["type"]
            if media_type == "application/x-shockwave-flash" or media_type.find(
                    "vmv") > -1 or media_type == "":
                continue

            try:
                description = XML.ElementFromString(e.description,
                                                    True).text_content()
            except:
                description = ""

            try:
                thumbnail = e["media_thumbnail"][0]["url"]
            except:
                thumbnail = ""

            try:
                content_url = e["media_content"][0]["url"]
            except:
                content_url = ""

            duration = ""

            title = e.title
            if secondTitle and title.find(secondTitle) == 0:
                title = title[len(secondTitle) + 1:]

            videoItem = VideoItem(id, title, description,
                                  duration + content_url, thumbnail)
            #   TODO: Set the metadata!
            #      videoItem.SetTelevisonMetadata(1,2,3)

            dir.AppendItem(videoItem)
            added = added + 1
            Log.Add("Read data for: " + title)
        except:
            Log.Add("Skipping item due to an error.")

    Log.Add("Total Videos: " + str(added))
    return dir.ToXML()
示例#8
0
def RecentVideosPage(url, title):
    dir = MediaContainer(FILE_DEFAULT_ART, title1=TEXT_IGN, title2=title)

    for link in LoadUrl(url, CACHE_INT_RECENT).xpath(XPATH_RECENT_VIDEOS_PAGE):
        url = link.get("href")
        name = link.find("img").get("alt")
        thumb = link.find("img").get("src")

        dir.AppendItem(CreateVideoItemFromPage(url, thumb, "", name))

    return dir.ToXML()
示例#9
0
def SelectedHit(index, title):
    dir = MediaContainer(FILE_DEFAULT_ART, title1=TEXT_IGN, title2=title)

    for video in HomePageXml().xpath(XPATH_SELECTED_HIT % index):
        desc = ""  # video.find("p") Why doesn't this return all of the p tags?
        url = video.find("a").get("href")
        thumb = video.find("a/img").get("src")
        title = video.find("h5/a").text
        dir.AppendItem(CreateVideoItemFromPage(url, thumb, desc, title))

    return dir.ToXML()
示例#10
0
def Latest():
    dir = MediaContainer(FILE_DEFAULT_ART,
                         title1=TEXT_IGN,
                         title2=TEXT_LATEST_VIDEOS)

    for video in HomePageXml().xpath(XPATH_LATEST_VIDEOS):
        videoPage = video.get("href")
        # Latest Videos are just a list, no thumbs
        dir.AppendItem(CreateVideoItemFromPage(videoPage))

    return dir.ToXML()
示例#11
0
def TopVideos():
    dir = MediaContainer(FILE_DEFAULT_ART,
                         title1=TEXT_IGN,
                         title2=TEXT_TOP_VIDEOS)

    for video in HomePageXml().xpath(XPATH_TOP_VIDEOS):
        videoPage = video.find('div/a').get("href")
        thumbUrl = video.find('div/a/img').get("src")
        dir.AppendItem(CreateVideoItemFromPage(videoPage, thumbUrl))

    return dir.ToXML()
示例#12
0
def HitList():
    dir = MediaContainer(FILE_DEFAULT_ART,
                         title1=TEXT_IGN,
                         title2=TEXT_HIT_LIST)

    count = 0
    for hit in HomePageXml().xpath(XPATH_HIT_LIST):
        count = count + 1
        dir.AppendItem(
            DirectoryItem(str(count) + "||" + hit.text, hit.text, None))

    return dir.ToXML()
示例#13
0
def getTivoEpisodes(tivoip, show_id, showname):
    dir = MediaContainer('art-default.jpg', title1="TiVo", title2=showname)
    url = "https://" + tivoip + ":443" + TIVO_LIST_PATH + "%2F" + show_id
    if showname == "HD Recordings" or showname == "TiVo Suggestions":
        return getTivoShowsByIPURL(tivoip, url, dir, 1)
    else:
        return getTivoShowsByIPURL(tivoip, url, dir, 0)
示例#14
0
def SelectedVideoSeries(url, title, limit=9999):
    dir = MediaContainer(FILE_DEFAULT_ART, title1=TEXT_IGN, title2=_D(title))

    xml = LoadUrl(url, CACHE_INT_VIDEO_SERIES)
    for episode in xml.xpath(XPATH_VIDEO_SERIES_EP):
        limit = limit - 1
        if limit < 0:
            dir.AppendItem(
                DirectoryItem(_E(url) + "||" + title, TEXT_ALL_EPISODES, None))
            break

        thumb = episode.find("a/img").get("src")
        desc = episode.find("a/img").get("alt")
        epUrl = episode.find("a").get("href")
        dir.AppendItem(CreateVideoItemFromPage(epUrl, thumb, desc))

    return dir.ToXML()
示例#15
0
def HandlePhotosRequest(pathNouns, count):
    dir_ = MediaContainer("art-default.jpg", "InfoList", "dinosaurcomics")
    global archived
    if archived == "new":
        archived = XML.ElementFromString(HTTP.GetCached(BASE_URL + "/archive.php", CACHE_TIME), True).xpath('//a[contains(@href, "www.qwantz.com/index.php?comic=")]')

    for item in archived[count*10:count*10+10]:
        try:
            title = item.text
            imgHTML = XML.ElementFromString(HTTP.GetCached(item.get("href"), CACHE_TIME), True).xpath('//img[contains(@class, "comic")]')[0]
            img = imgHTML.get("src")
            desc = imgHTML.get("title")
            ph = PhotoItem(img, title, desc, img)
            dir_.AppendItem(ph)
        except Exception, e:
            Log.Add("Exception caught when trying to fetch comic:")
            Log.Add("\t" + str(e))
            Log.Add("\t" + item.get("href"))
示例#16
0
def VideoSeries(all=False):
    dir = MediaContainer(FILE_DEFAULT_ART,
                         title1=TEXT_IGN,
                         title2=TEXT_VIDEO_SERIES)

    if all:  # From Video Series page
        for series in LoadUrl(
                URL_VIDEO_SERIES,
                CACHE_INT_SERIES_LIST).xpath(XPATH_ALL_VIDEO_SERIES):
            thumb = series.find("a/img").get("src")
            title = series.find("a/img").get("alt")
            url = series.find("a").get("href")
            dir.AppendItem(
                DirectoryItem(_E(url) + "||" + _E(title), title, thumb))

    else:  # From Home page
        for series in HomePageXml().xpath(XPATH_VIDEO_SERIES):
            url = series.get("href")
            name = series.find("img").get("alt")
            thumb = series.find("img").get("src")
            dir.AppendItem(
                DirectoryItem(_E(url) + "||" + _E(name), name, thumb))
        dir.AppendItem(DirectoryItem("all", TEXT_ALL_SERIES, None))

    return dir.ToXML()
示例#17
0
def getTivoShows(tivoName):
    dir = MediaContainer('art-default.jpg', title1="TiVo", title2=tivoName)

    p1 = Popen(["mDNS", "-L", tivoName, "_tivo-videos._tcp", "local"],
               stdout=PIPE)
    p2 = Popen(["grep", "443"], stdin=p1.stdout, stdout=PIPE)
    p3 = Popen(["cut", "-c", "43-57"], stdin=p2.stdout, stdout=PIPE)
    sleep(2)
    kill(p1.pid, SIGTERM)
    tivolines = p3.communicate()[0]
    tivoip = tivolines.split()[0]
    url = "https://" + tivoip + ":443" + TIVO_LIST_PATH
    return getTivoShowsByIPURL(tivoip, url, dir, 1)
示例#18
0
def Index():
    dir = MediaContainer(FILE_DEFAULT_ART, title1=TEXT_IGN)

    xml = HomePageXml()

    # "Exclusive" video is not always there
    exclusiveLinks = xml.xpath('//div[@id="video_exclusive"]//a')
    if len(exclusiveLinks) > 1:
        videoPage = exclusiveLinks[1].get("href")
        thumbUrl = xml.xpath('//div[@id="video_exclusive"]//a[1]/img')[0].get(
            "src")
        dir.AppendItem(CreateVideoItemFromPage(videoPage, thumbUrl))

    dir.AppendItem(DirectoryItem(PATH_TOP_VIDEOS, TEXT_TOP_VIDEOS, ""))
    dir.AppendItem(DirectoryItem(PATH_LATEST_VIDEOS, TEXT_LATEST_VIDEOS, ""))
    dir.AppendItem(DirectoryItem(PATH_VIDEO_SERIES, TEXT_VIDEO_SERIES, ""))
    dir.AppendItem(DirectoryItem(PATH_HIT_LIST, TEXT_HIT_LIST, ""))
    dir.AppendItem(DirectoryItem(PATH_GAME_TRAILERS, TEXT_GAME_TRAILERS, ""))
    dir.AppendItem(DirectoryItem(PATH_MOVIE_TRAILERS, TEXT_MOVIE_TRAILERS, ""))
    dir.AppendItem(DirectoryItem(PATH_REVIEWS, TEXT_REVIEWS, ""))
    dir.AppendItem(DirectoryItem(PATH_PREVIEWS, TEXT_PREVIEWS, ""))
    dir.AppendItem(DirectoryItem(PATH_RECENT_VIDEOS, TEXT_RECENT_VIDEOS, ""))

    return dir.ToXML()
示例#19
0
def HandleRequest(pathNouns, count):
    user_id = Prefs.Get("user_id")
    device_code = Prefs.Get("device_code")

    Log.Add("Handling request for paths " + (",".join(pathNouns)))

    if count == 0:
        dir = MediaContainer('art-default.jpg', None, "Channels")
        dir.AppendItem(
            DirectoryItem("most_watched_week", "Most Watched This Week", ""))
        dir.AppendItem(
            DirectoryItem("most_watched_all", "Most Watched All Time", ""))
        dir.AppendItem(
            DirectoryItem("most_watched_month", "Most Watched This Month", ""))
        dir.AppendItem(
            DirectoryItem("newest_videos_week", "Newest Videos This Week", ""))
        dir.AppendItem(
            DirectoryItem("newest_videos_today", "Newest Videos Today", ""))
        dir.AppendItem(
            SearchDirectoryItem("search", "Search", "Search Channels.com",
                                Plugin.ExposedResourcePath("search.png")))
        dir.AppendItem(DirectoryItem("my_feed", "My Feed", ""))

        if user_id != None:
            dir.AppendItem(
                SearchDirectoryItem(
                    "pref^user_id",
                    "Change Channels User Id [" + user_id + "]",
                    "Change your Channels User ID.", ""))
        else:
            dir.AppendItem(
                SearchDirectoryItem(
                    "pref^user_id", "Set your User ID",
                    "Go to Edit Profile - Tools and see your user ID.", ""))

        if device_code != None:
            dir.AppendItem(
                SearchDirectoryItem(
                    "pref^device_code",
                    "Change Channels Device Code [" + device_code + "]",
                    "Change your Channels Device Code.", ""))
        else:
            dir.AppendItem(
                SearchDirectoryItem(
                    "pref^device_code", "Set your Device Code",
                    "Go to Edit Profile - Tools and see your Device Code.",
                    ""))

        return dir.ToXML()

    elif pathNouns[0] == "most_watched_week":
        url = CHANNELS_URL + "popular/videos/week?format=rss"
        Log.Add("Loading " + url)
        return populateFromFeed(url, "Most Watched This Week")
    elif pathNouns[0] == "most_watched_month":
        url = CHANNELS_URL + "popular/videos/month?format=rss"
        Log.Add("Loading " + url)
        return populateFromFeed(url, "Most Watched This Month")
    elif pathNouns[0] == "most_watched_all":
        url = CHANNELS_URL + "popular/videos/all?format=rss"
        Log.Add("Loading " + url)
        return populateFromFeed(url, "Most Watched All Time")
    elif pathNouns[0] == "newest_videos_today":
        url = CHANNELS_URL + "newest/videos/today?format=rss"
        Log.Add("Loading " + url)
        return populateFromFeed(url, "Newest Videos Today")
    elif pathNouns[0] == "newest_videos_week":
        url = CHANNELS_URL + "newest/videos/week?format=rss"
        Log.Add("Loading " + url)
        return populateFromFeed(url, "Newest Videos This Week")
    elif pathNouns[0] == "my_feed":
        Log.Add("Handling my feed only if user_id and device_code are there.")
        if user_id != None and device_code != None:
            url = CHANNELS_URL + "device_feed?format=rss&user_id=" + user_id + "&device_code=" + device_code
            Log.Add("Loading " + url)
            return populateFromFeed(url, "My Feed")
    elif pathNouns[0].startswith("pref"):
        if count == 2:
            field = pathNouns[0].split("^")[1]
            Prefs.Set(field, pathNouns[1])
            if field == "user_id":
                dir.SetMessage("Channels Preferences", "Channels User ID Set.")
            else:
                dir.SetMessage("Channels Preferences",
                               "Channels Device Code Set")

    elif pathNouns[0] == "search":
        if count > 1:
            query = pathNouns[1]
            if count > 2:
                for i in range(2, len(pathNouns)):
                    query += "/%s" % pathNouns[i]
            return populateFromFeed(
                CHANNELS_SEARCH_URL + urllib.quote_plus(query),
                "Query: " + query)
示例#20
0
def HandleVideosRequest(pathNouns, count):
  dir = MediaContainer("art-default.png", "", "")
  if count == 0:
    dir = Index()
    
  elif count > 3: 
    if pathNouns[1] == "parties":
      if pathNouns[3] == "all_years":
        dir = GetFeedDirectory("lastreleased&party=" + pathNouns[2])
      else:
        dir = GetFeedDirectory("lastreleased&party=" + pathNouns[2] + "&yearofparty=" + pathNouns[3]) 
      
  elif count > 2:  
    if pathNouns[1] == "groups": 
      dir = GetFeedDirectory("lastreleased&group=" + pathNouns[2])  
    elif pathNouns[1] == "parties":
      dir = GetPartyYears(pathNouns[2]);  
      
  elif count > 1:
    Debug("pathNouns, count",  pathNouns[0] +"/"+ pathNouns[1] +", "+ str(count))
    if pathNouns[1] == "lastadded":
      dir = GetFeedDirectory("lastadded")
    elif pathNouns[1] == "lastreleased":
      dir = GetFeedDirectory("lastreleased")
    elif pathNouns[1] == "topweek":
      dir = GetFeedDirectory("topweek")
    elif pathNouns[1] == "topmonth":
      dir = GetFeedDirectory("topmonth")
    elif pathNouns[1] == "alltimetop":
      dir = GetFeedDirectory("alltimetop")
    elif pathNouns[1] == "toprating":
      dir = GetFeedDirectory("alltimetop")
    elif pathNouns[1] == "groups": 
      dir = GetList("listofgroups")
    elif pathNouns[1] == "parties": 
      dir = GetList("listofparties")

  return dir.ToXML()
示例#21
0
def Index():
  dir = MediaContainer("art-default.png", "Details", "demoscene.tv")
  dir.AppendItem(DirectoryItem("cat/lastadded", GetJsonQueryTitle("lastadded"), _R("icon-default.png"), GetJsonQueryDescription("lastadded")))
  dir.AppendItem(DirectoryItem("cat/lastreleased", GetJsonQueryTitle("lastreleased"), _R("icon-default.png"), GetJsonQueryDescription("lastreleased")))
  dir.AppendItem(DirectoryItem("cat/topweek", GetJsonQueryTitle("topweek"), _R("icon-default.png"), GetJsonQueryDescription("topweek")))
  dir.AppendItem(DirectoryItem("cat/topmonth", GetJsonQueryTitle("topmonth"), _R("icon-default.png"), GetJsonQueryDescription("topmonth")))
  dir.AppendItem(DirectoryItem("cat/alltimetop", GetJsonQueryTitle("alltimetop"), _R("icon-default.png"), GetJsonQueryDescription("alltimetop")))
  dir.AppendItem(DirectoryItem("cat/toprating", GetJsonQueryTitle("toprating"), _R("icon-default.png"), GetJsonQueryDescription("toprating")))
  dir.AppendItem(DirectoryItem("cat/groups", GetJsonQueryTitle("listofgroups"), _R("icon-default.png"), GetJsonQueryDescription("listofgroups")))
  dir.AppendItem(DirectoryItem("cat/parties", GetJsonQueryTitle("listofparties"), _R("icon-default.png"), GetJsonQueryDescription("listofparties")))
  dir.AppendItem(WhatIsDemoScene())
  return dir