[WebInterface] - forward opener for externals to have access to functions of WebInterface
[enigma2-plugins.git] / src / Additions / mp4porn.py
1 # mp4porn plugin by AliAbdul
2 from Plugin import Movie, Plugin
3 import re, urllib2
4
5 ##################################################
6
7 class MP4PornMovie(Movie):
8         def __init__(self, name, url, thumb):
9                 Movie.__init__(self, name, url, thumb)
10
11         def getVideoUrl(self):
12                 try:
13                         data = urllib2.urlopen(self.url).read()
14                 except:
15                         data = ""
16                 reonecat = re.compile(r'\| <a href="(.+?).m4v"')
17                 list = reonecat.findall(data)
18                 if list and len(list) > 0:
19                         return "%s%s" % (list[0], ".m4v")
20                 else:
21                         return None
22
23 ##################################################
24
25 class MP4Porn(Plugin):
26         def __init__(self):
27                 self.moreEntries = True
28                 Plugin.__init__(self, "mp4porn.mobi", "mp4porn.png")
29
30         def getEntries(self, callback, currPage=1):
31                 self.currPage = currPage
32                 self.callback = callback
33                 self.getPage("http://mp4porn.mobi/page/%d/" % self.currPage)
34
35         def getPageCallback(self, page):
36                 movies = []
37                 reonecat = re.compile(r'<div class="post" onclick="location.href=(.+?)"> <div class="thumb"><a href="(.+?)"><img src="(.+?)" width="120" height="90" alt="(.+?)" />', re.DOTALL)\r
38                 for unneeded, url, thumb, name in reonecat.findall(page):
39                         movies.append(MP4PornMovie(name, url, thumb))
40                 self.callback(movies)
41
42         def getMoreEntries(self):
43                 if self.moreEntries:
44                         self.getEntries(self.callback, self.currPage+1)
45
46         def getPageError(self, error=None):
47                 if error and self.currPage == 1:
48                         print "[%s] Error: %s" % (self.name, error)
49                 else:
50                         self.moreEntries = False
51
52 ##################################################
53
54 def getPlugin():
55         return MP4Porn()