[9640d5]: plugin.video.pantoffel_tv / default.py Maximize Restore History

Download this file

default.py    108 lines (92 with data), 4.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
#!/usr/bin/python
# -*- coding: utf-8 -*-
import urllib
import urllib2
import random
import re
import xbmc
import xbmcgui
import xbmcaddon
import xbmcplugin
addon = xbmcaddon.Addon()
pluginhandle = int(sys.argv[1])
forceViewMode = addon.getSetting("forceViewMode") == "true"
viewMode = str(addon.getSetting("viewMode"))
urlMain = "http://pantoffel.tv"
def index():
xbmcplugin.setContent(pluginhandle, "episodes")
content = getUrl(urlMain+"/magazin/")
spl = content.split('<h1 class="magtitle"')
for i in range(1, len(spl), 1):
entry = spl[i]
match = re.compile('>(.+?)<', re.DOTALL).findall(entry)
title = cleanTitle(match[0])
match = re.compile('<small class="pull-right">(.+?)</small>', re.DOTALL).findall(entry)
desc1 = cleanTitle(match[0])
match = re.compile('<p style=".+?">(.+?)</p>', re.DOTALL).findall(entry)
desc2 = cleanTitle(match[0])
desc = desc1+"\n"+desc2
if " " in title:
nr = title.split(" ")[1]
else:
nr = "1"
length = desc1.split(" ")[0]
date = desc1.split("/")[1].strip()
splDate = date.split(".")
date = splDate[2]+"-"+splDate[1]+"-"+splDate[0]
match = re.compile('<a href="/watch/(.+?)"', re.DOTALL).findall(entry)
url = urlMain+"/watch/"+match[0]
match = re.compile('src="(.+?)"', re.DOTALL).findall(entry)
thumb = match[0]
addLink(title, url, 'playVideo', thumb, length, desc, date, nr)
if forceViewMode:
xbmc.executebuiltin('Container.SetViewMode('+viewMode+')')
xbmcplugin.endOfDirectory(pluginhandle)
def playVideo(url):
content = getUrl(url)
content = content[content.find('playlist = ['):]
content = content[:content.find('];')]
match = re.compile("'(.+?)'", re.DOTALL).findall(content)
urlFull="stack://"
for file in match:
urlFull += 'http://dl' + str(random.randint(2, 3)) + '.fernsehkritik.tv/deliver/ptv/limited/ptv' + file + " , "
urlFull=urlFull[:-3]
listitem = xbmcgui.ListItem(path=urlFull)
xbmcplugin.setResolvedUrl(pluginhandle, True, listitem)
def cleanTitle(title):
title = title.replace("&lt;", "<").replace("&gt;", ">").replace("&amp;", "&").replace("&#39;", "'").replace("&quot;", "\"").replace("&szlig;", "��").replace("&ndash;", "-")
title = title.replace("&#38;", "&").replace("&#8230;", "...").replace("&#8211;", "-").replace("&#8220;", "-").replace("&#8221;", "-").replace("&#8217;", "'")
title = title.replace("&#196;", "��").replace("&#220;", "��").replace("&#214;", "��").replace("&#228;", "��").replace("&#252;", "��").replace("&#246;", "��").replace("&#223;", "��").replace("&#176;", "��").replace("&#233;", "��").replace("&#224;", "��")
title = title.strip()
return title
def getUrl(url):
req = urllib2.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0')
response = urllib2.urlopen(req)
link = response.read()
response.close()
return link
def parameters_string_to_dict(parameters):
paramDict = {}
if parameters:
paramPairs = parameters[1:].split("&")
for paramsPair in paramPairs:
paramSplits = paramsPair.split('=')
if (len(paramSplits)) == 2:
paramDict[paramSplits[0]] = paramSplits[1]
return paramDict
def addLink(name, url, mode, iconimage, length, desc, date, nr):
u = sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)
ok = True
liz = xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage)
liz.setInfo(type="Video", infoLabels={"Title": name, "Duration": length, "Plot": desc, "Aired": date, "Episode": nr})
liz.setProperty('IsPlayable', 'true')
ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz)
return ok
params = parameters_string_to_dict(sys.argv[2])
mode = urllib.unquote_plus(params.get('mode', ''))
url = urllib.unquote_plus(params.get('url', ''))
if mode == 'playVideo':
playVideo(url)
else:
index()