2015-05-04, 14:12
this script connects to my youtube playlists
but i cant create more than 3 playlist in the code, when i try i get an error.
my youtube page got more than 3 playlist and i like to add them all.
why cant i add this line ?
add_cat("funny", "PLDJaTrOWNLOaiDeljojKva-oxOonSMSFe")
but i cant create more than 3 playlist in the code, when i try i get an error.
my youtube page got more than 3 playlist and i like to add them all.
why cant i add this line ?
add_cat("funny", "PLDJaTrOWNLOaiDeljojKva-oxOonSMSFe")
Code:
# -*- coding: utf-8 -*-
#------------------------------------------------------------
# http://www.youtube.com/user/GoProCamera
#------------------------------------------------------------
# License: GPL (http://www.gnu.org/licenses/gpl-3.0.html)
# Based on code from youtube addon
#------------------------------------------------------------
import os
import sys
import plugintools
start_index = 1
amount = 30
def add_cat(name, playlist_id):
plugintools.add_item( action="main_list" , title=name , url="?pid=" + playlist_id + "&start-index=1&max-results=30" ,thumbnail="" , folder=True )
# Entry point
def run():
plugintools.log("UCaITL2fxK1nbxrT-DwdhwQQ.run")
# Get params
params = plugintools.get_params()
if params.get("action") is None:
category_list(params)
if params.get("action")=="main_list":
main_list(params)
else:
action = params.get("action")
exec action+"(params)"
plugintools.close_item_list()
# Categories
def category_list(params):
add_cat("live shows", "PLDJaTrOWNLOYHLweDSzVn_-f8cbfgfhRM")
add_cat("stand up", "PLDJaTrOWNLOYtY4hxm_j49b_RVa8sGQ9i")
add_cat("childrens", "PLDJaTrOWNLOYbV-X3_C-8I-GpyX8XZWjQ")
# Main menu
def main_list(params):
plugintools.log("UCaITL2fxK1nbxrT-DwdhwQQ.main_list "+repr(params))
# On first page, pagination parameters are fixed
if params.get("url") is not None:
pid = plugintools.find_single_match( params.get("url") ,"pid=(.+?)&")
start_index = plugintools.find_single_match( params.get("url") ,"start-index=(\d+)")
max_results = plugintools.find_single_match( params.get("url") ,"max-results=(\d+)")
p_url = "http://gdata.youtube.com/feeds/api/playlists/"+pid+"/?start-index=" + start_index + "&max-results=" + max_results
plugintools.log("MYPID "+p_url)
# Fetch video list from YouTube feed
data = plugintools.read( p_url )
# Extract items from feed
pattern = ""
matches = plugintools.find_multiple_matches(data,"<entry>(.*?)</entry>")
for entry in matches:
# Not the better way to parse XML, but clean and easy
title = plugintools.find_single_match(entry,"<titl[^>]+>([^<]+)</title>")
plot = plugintools.find_single_match(entry,"<media\:descriptio[^>]+>([^<]+)</media\:description>")
thumbnail = plugintools.find_single_match(entry,"<media\:thumbnail url='([^']+)'")
video_id = plugintools.find_single_match(entry,"http\://www.youtube.com/watch\?v\=([^\&]+)\&").replace("&","&")
url = "plugin://plugin.video.youtube/?path=/root/video&action=play_video&videoid="+video_id
# Appends a new item to the xbmc item list
plugintools.add_item( action="play" , title=title , plot=plot , url=url ,thumbnail=thumbnail , folder=True )
# Calculates next page URL from actual URL
start_index = str(int(start_index) + int(max_results))
if params.get("url") is not None:
next_page_url = "?pid=" + pid + "&start-index=" + start_index + "&max-results=" + max_results
plugintools.add_item( action="main_list" , title=">> Next page" , url=next_page_url, folder=True )
def play(params):
plugintools.play_resolved_url( params.get("url") )
run()
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.Il-Stream"
name="Il-Stream"
version="1.0"
provider-name="Il-Stream">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="plugin.video.youtube" version="3.0.0"/>
</requires>
<extension point="xbmc.python.pluginsource" library="default.py">
<provides>video</provides>
</extension>
<extension point="xbmc.addon.metadata">
<summary lang="en">Watch For Free</summary>
<description lang="en">Il-Stream</description>
<platform>all</platform>
</extension>
</addon>