2015-11-02, 18:00
I'm making an add on to view videos from a site called crazyshit. It already loads the first page of videos and I'm aple to play them but how can I add a directory item to load the next page? Is there an event or how does that work? I'm new to python and kodi but I will link to my zip and post my source code. I'm a prrogrammer but I'm very new to python and even newer to Kodi.
Zip File for the add on here
Zip File for the add on here
Code:
#!/usr/bin/env python
import sys
import xbmcgui
import xbmcplugin
import urllib
import urlparse
import re
url = "http://www.crazyshit.com/?show="
pagenum = 1
vidlinks = []
videos= []
piclinks = []
pictures = []
html = ''
def loadpage(page):
try:
html = urllib.urlopen(page).read()
b = re.findall(r'<div class="contentCell">.*?<div class="clearBoth">', html, re.S)
html = ''
for e in b:
html += e
y = re.findall(r'<a[^>]*href="(.*?)"', html)
for g in y:
if '/cnt/' in g:
if '/cnt/medias/' in g:
if urlparse.urljoin(page,g) not in vidlinks:
vidlinks.append(urlparse.urljoin(page,g))
except:
pass
def main():
loadpage(url + str(pagenum))
addon_handle = int(sys.argv[1])
xbmcplugin.setContent(addon_handle, 'movies')
for x in vidlinks:
html = urllib.urlopen(x).read()
try:
li = xbmcgui.ListItem(label = re.findall(r'<meta property="og:title" content="(.*?)"/>', html, re.S)[0])
vid = re.findall(r'<source src="(.*?)" type=', html, re.S)[0]
img = re.findall(r'<video.*?poster="(.*?)".*?data-setup', html, re.S)[0]
li.setIconImage(img)
plot = re.findall(r'<div id="content-text">(.*?)</div>', html, re.S)[0]
plot = re.sub(r'<.*?>', '', plot)
li.setInfo( type="Video", infoLabels={ "Plot" : plot })
li.setArt({ "fanart" : img })
xbmcplugin.addDirectoryItem(handle=addon_handle, url=vid,listitem=li,totalItems=len(vidlinks))
except:
pass
xbmcplugin.endOfDirectory(addon_handle)
main()