Browse Source

salabots ltc, filmix, cinemalive

Ivars 7 years ago
parent
commit
3b5eab8a95
8 changed files with 887 additions and 523 deletions
  1. 9
    3
      ContentSources.py
  2. BIN
      icon.gif
  3. 606
    359
      project.wpr
  4. 65
    19
      run.py
  5. 107
    80
      sources/cinemalive.py
  6. 74
    33
      sources/filmix.py
  7. 13
    15
      sources/replay.py
  8. 13
    14
      sources/streams.cfg

+ 9
- 3
ContentSources.py View File

128
             source = data.split("::")[0]
128
             source = data.split("::")[0]
129
             if source in self.plugins:
129
             if source in self.plugins:
130
                 if "get_info" in dir(self.plugins[source]):
130
                 if "get_info" in dir(self.plugins[source]):
131
-                    streams = self.get_streams(data)
132
-                    nfo = streams[0]["nfo"] if streams and "nfo" in streams[0] else {}
133
-                else:
134
                     nfo = self.plugins[source].get_info(data)
131
                     nfo = self.plugins[source].get_info(data)
132
+                else:
133
+                    streams = self.get_streams(data)
134
+                    if streams and "nfo" in streams[0] and streams[0]["nfo"]:
135
+                        nfo = streams[0]["nfo"]
136
+                    else:
137
+                        nfo = {"movie": {"title": current[0], "thumb": self.current[2], "plot": self.current[3]}}
138
+
139
+
140
+
135
         else:
141
         else:
136
             pass    # TODO create nfo for listing
142
             pass    # TODO create nfo for listing
137
         return nfo
143
         return nfo

BIN
icon.gif View File


+ 606
- 359
project.wpr
File diff suppressed because it is too large
View File


+ 65
- 19
run.py View File

24
         self.root = Tk()
24
         self.root = Tk()
25
         self.root.geometry("1050x600")
25
         self.root.geometry("1050x600")
26
         Frame.__init__(self, self.root)
26
         Frame.__init__(self, self.root)
27
-        #self.pack()
27
+        img = PhotoImage(file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'icon.gif'))
28
+        #img = PhotoImage(file= 'icon.gif')
29
+        self.root.tk.call('wm', 'iconphoto', self.root._w, img)
28
         self.pack(fill=BOTH, expand=1)
30
         self.pack(fill=BOTH, expand=1)
29
         self.initUI()
31
         self.initUI()
30
         items = ["item %s" % i for i in range(20)]
32
         items = ["item %s" % i for i in range(20)]
32
             self.sources = sources
34
             self.sources = sources
33
         else:
35
         else:
34
             self.sources = ContentSources("sources")
36
             self.sources = ContentSources("sources")
35
-        self.picons_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "picons")
36
-        self.tmp_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "tmp")
37
+        self.picons_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "picons")
38
+        self.tmp_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "tmp")
37
         if not os.path.exists(self.tmp_path):
39
         if not os.path.exists(self.tmp_path):
38
             os.mkdir(self.tmp_path)
40
             os.mkdir(self.tmp_path)
39
         self.history = []
41
         self.history = []
98
                             command=self.quit, width=10)
100
                             command=self.quit, width=10)
99
         self.b_exit.pack(side=LEFT, anchor=S)
101
         self.b_exit.pack(side=LEFT, anchor=S)
100
 
102
 
101
-    def list_select(self):
102
-        w = evt.widget
103
-        cs = int(w.curselection()[0])
104
-        value = w.get(cs)
105
-        #print 'You selected item %d: "%s"' % (index, value)
106
-
107
-    def list_key(self, evt):
108
-        w = evt.widget
109
-        cs = int(w.curselection()[0])
110
-        value = w.get(cs)
111
-        key = evt.keysym
112
-        #print 'Key %s' % (key)
113
-        self.cur_index = cs
114
-        self.list_action(key)
115
 
103
 
116
     def list_action(self, evt=None, key=None):
104
     def list_action(self, evt=None, key=None):
117
         cs = int(self.listbox.curselection()[0])
105
         cs = int(self.listbox.curselection()[0])
120
             w = evt.widget
108
             w = evt.widget
121
             value = w.get(cs)
109
             value = w.get(cs)
122
             key = evt.keysym
110
             key = evt.keysym
123
-        print 'Key %s' % (key)
111
+        #print 'Key: %s' % (key)
124
         data = self.content[cs][1]
112
         data = self.content[cs][1]
125
         cur2 = self.content[cs]
113
         cur2 = self.content[cs]
126
 
114
 
169
             index2 = max(index2, 0)
157
             index2 = max(index2, 0)
170
             self.set_list_item(index2)
158
             self.set_list_item(index2)
171
 
159
 
160
+        elif key in ("i", "I"):
161
+            print "TODO - indo"
162
+
172
     def set_list_item(self, index):
163
     def set_list_item(self, index):
173
         self.cur_index = index
164
         self.cur_index = index
174
         self.listbox.selection_clear(0, END)
165
         self.listbox.selection_clear(0, END)
197
         self.desc.config(state=NORMAL)
188
         self.desc.config(state=NORMAL)
198
         self.desc.delete("1.0", END)
189
         self.desc.delete("1.0", END)
199
         self.desc.insert(END, self.content[cs][3])
190
         self.desc.insert(END, self.content[cs][3])
200
-        self.desc.insert(END, "\n\n"+self.content[cs][2])
191
+        self.desc.insert(END, "\n\n"+self.content[cs][1])
192
+        self.desc.insert(END, "\n"+self.content[cs][2])
201
         self.desc.config(state=DISABLED)
193
         self.desc.config(state=DISABLED)
202
 
194
 
203
     def show_pic(self):
195
     def show_pic(self):
204
         cs = self.listbox.curselection()[0]
196
         cs = self.listbox.curselection()[0]
205
         img = self.content[cs][2]
197
         img = self.content[cs][2]
206
         self.pic.delete(ALL)
198
         self.pic.delete(ALL)
199
+        if not img:
200
+            return
207
         if not img.startswith("http"):
201
         if not img.startswith("http"):
208
             img_path = os.path.join(self.picons_path, img)
202
             img_path = os.path.join(self.picons_path, img)
209
             if img and os.path.exists(img_path):
203
             if img and os.path.exists(img_path):
210
                 im =  Image.open(img_path)
204
                 im =  Image.open(img_path)
211
             else:
205
             else:
212
                 im = None
206
                 im = None
207
+                print "No image found ", img_path
213
         elif img:
208
         elif img:
214
             fcache = img.replace(":", "_").replace("/", "-").replace(":", "_")
209
             fcache = img.replace(":", "_").replace("/", "-").replace(":", "_")
215
             fcache = os.path.join(self.tmp_path, fcache)
210
             fcache = os.path.join(self.tmp_path, fcache)
250
             if len(streams) > 1:
245
             if len(streams) > 1:
251
                 lst = []
246
                 lst = []
252
                 for i,s in enumerate(streams):
247
                 for i,s in enumerate(streams):
248
+                    s =  {k:v.decode("utf8") if v and isinstance(v, str) else v for k,v in zip(s.keys(), s.values())}
253
                     lst.append(("[%s,%s] %s"%(s["lang"],s["quality"],s["name"]),i))
249
                     lst.append(("[%s,%s] %s"%(s["lang"],s["quality"],s["name"]),i))
254
                 a = ChoiceBox("ChoiceBox test", "Select stream", lst, parent=self, width=40).result
250
                 a = ChoiceBox("ChoiceBox test", "Select stream", lst, parent=self, width=40).result
255
                 stream = streams[a]
251
                 stream = streams[a]
335
     def apply(self):
331
     def apply(self):
336
         self.result = self.listbox.curselection()[0]
332
         self.result = self.listbox.curselection()[0]
337
 
333
 
334
+class Info(tkd.Dialog):
335
+    #a = ChoiceBox("ChoiceBox test", "Select stream", items, parent=self).result
336
+    def __init__(self, title, items, width=20, height=15,
337
+                 initialvalue=0, parent = None):
338
+        if not parent:
339
+            import Tkinter
340
+            parent = Tkinter._default_root
341
+        self.prompt = prompt
342
+        self.items = items
343
+        self.width = width
344
+        self.height = height
345
+        self.result = None
346
+        self.initialvalue = initialvalue
347
+        tkd.Dialog.__init__(self, parent, title)
348
+
349
+    def body(self, master):
350
+        w = Label(self, text=self.prompt, justify=LEFT)
351
+        w.pack(side=TOP)
352
+        frame1 = Frame(self)
353
+        frame1.pack(side=TOP, fill=X, expand=1, padx=5)
354
+        scrollbar = Scrollbar(frame1, orient=VERTICAL)
355
+        self.listbox = Listbox(frame1, yscrollcommand=scrollbar.set, width=self.width, height=self.height)
356
+        scrollbar.config(command=self.listbox.yview)
357
+        #self.listbox.config(yscrollcommand=scrollbar.set)
358
+        self.listbox.pack(side=LEFT, fill=BOTH, expand=1)
359
+        scrollbar.pack(side=LEFT, fill=Y)
360
+        for item in self.items:
361
+            self.listbox.insert(END, item)
362
+        self.listbox.selection_set(self.initialvalue)
363
+        self.listbox.activate(self.initialvalue)
364
+        self.listbox.bind('<Double-1> ', self.list_select)
365
+        self.listbox.bind('<Key> ', self.list_key)
366
+        self.update()
367
+        self.geometry("+%d+%d"%(self.parent.winfo_rootx()+100, self.parent.winfo_rooty()+100 ))
368
+        return self.listbox
369
+
370
+    def list_key(self, evt):
371
+        key = evt.keysym
372
+        #print 'Key %s' % (key)
373
+        if key == "Return":
374
+            self.ok()
375
+        elif key == "Escape":
376
+            self.cancel()
377
+
378
+    def list_select(self, evt):
379
+        self.ok()
380
+
381
+    def apply(self):
382
+        self.result = self.listbox.curselection()[0]
383
+
338
 
384
 
339
 def run(sources=None, data="config::home", title="Home"):
385
 def run(sources=None, data="config::home", title="Home"):
340
     app = Main(sources)
386
     app = Main(sources)

+ 107
- 80
sources/cinemalive.py View File

31
 class Source(SourceBase):
31
 class Source(SourceBase):
32
 
32
 
33
     def __init__(self,country="",cfg_path=None):
33
     def __init__(self,country="",cfg_path=None):
34
-        self.hidden = True # nerāda menu nestrādājošos avotus
34
+        #self.hidden = True # nerāda menu nestrādājošos avotus
35
         self.name = "cinemalive"
35
         self.name = "cinemalive"
36
         self.title = "cinemalive.tv"
36
         self.title = "cinemalive.tv"
37
-        self.img = "cinemalive..png" #"https://cinemalive.tv/assets/img/logo.png"
38
-        self.desc = "cinemalive.tv satura skatīšanās"
37
+        self.img = "cinemalive.png" #"https://cinemalive.tv/assets/img/logo.png"
38
+        self.desc = "Filmas latviski"
39
         self.country=country
39
         self.country=country
40
         self.headers = headers2dict("""
40
         self.headers = headers2dict("""
41
 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0
41
 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0
59
 
59
 
60
         if clist=="home":
60
         if clist=="home":
61
             content.extend([
61
             content.extend([
62
-                ("Search", "cinemalive::scripts/search.php?search={0}","","Search"),
63
-                ("Filmas latviski - visas", "cinemalive::filmaslatviski/visas/lapa/1","","Filmas latviski - visas"),
62
+                ("Search", "cinemalive::?s={0}","","Search"),
63
+                #("Filmas latviski - visas", "cinemalive::filmaslatviski/","","Filmas latviski - visas"),
64
                 ("Filmas angliski", "cinemalive::home_en","","Filmas angliski"),
64
                 ("Filmas angliski", "cinemalive::home_en","","Filmas angliski"),
65
-                ("Filmas latviski - jaunākās", "cinemalive::filmaslatviski/jaunakas/lapa/1","","Filmas latviski - jaunākās"),
66
-                ("Filmas latviski - vertētākās", "cinemalive::filmaslatviski/vertetakas/lapa/1","","Filmas latviski - vērtētākās"),
67
-                ("Filmas latviski - skatitakās", "cinemalive::filmaslatviski/skatitakas/lapa/1","","Filmas latviski - skatītākās"),
65
+                #("Filmas latviski - jaunākās", "cinemalive::filmaslatviski/?get=jaunakas","","Filmas latviski - jaunākās"),
66
+                #("Filmas latviski - vertētākās", "cinemalive::filmaslatviski/?get=vertetakas","","Filmas latviski - vērtētākās"),
67
+                #("Filmas latviski - skatitakās", "cinemalive::filmaslatviski/?get=skatitakas","","Filmas latviski - skatītākās"),
68
+                #("Filmas latviski - animācija", "cinemalive::genre/animacija/","","Filmas latviski - animacijas"),
69
+                #("Filmas latviski - ģimenes", "cinemalive::genre/gimenes/","","Filmas latviski - ģimenes"),
68
             ])
70
             ])
69
             r = self.call("filmaslatviski")
71
             r = self.call("filmaslatviski")
70
-            for item in re.findall(r'<li class="nav-submenu-item"><a href="/([\w/]+)">(.+?)</a></li>', r):
72
+            i0 = r.find('<div class="menu">')
73
+            result = re.findall(r'menu-item-41\d+"><a href="([^"]+)">([^<]+)</a>', r[i0:])
74
+            for item in result:
71
                 title = "Filmas latviski - "+item[1]
75
                 title = "Filmas latviski - "+item[1]
72
-                data2 = item[0]+"/lapa/1"
76
+                data2 = item[0].replace("https://cinemalive.tv", "")  #+"lapa/1/"
77
+                data2 = data2[1:]
73
                 img = self.img
78
                 img = self.img
74
                 desc = title
79
                 desc = title
75
                 content.append((title,self.name+"::"+data2,img,desc))
80
                 content.append((title,self.name+"::"+data2,img,desc))
77
 
82
 
78
         elif clist=="home_en":
83
         elif clist=="home_en":
79
             content.extend([
84
             content.extend([
80
-                ("Search", "cinemalive::scripts/search.php?search={0}","","Search"),
81
-                ("Movies English - all", "cinemalive::moviesenglish/all/page/1","","Movies English - all"),
82
-                ("Movies Latvian", "cinemalive::home","","Filmas latviski"),
83
-                ("Movies English - newest", "cinemalive::moviesenglish/newestmovies/page/1","","Movies English - newest"),
84
-                ("Movies English - top rated", "cinemalive::moviesenglish/toprated/page/1","","Movies English - top rated"),
85
-                ("Movies English - most watched", "cinemalive::moviesenglish/mostwatched/page/1","","Movies English - most watched"),
85
+                ("Search", "cinemalive::?s={0}","","Search"),
86
+                #("Movies English - all", "cinemalive::moviesenglish/all/page/1","","Movies English - all"),
87
+                #("Movies Latvian", "cinemalive::home","","Filmas latviski"),
88
+                #("Movies English - newest", "cinemalive::moviesenglish/newestmovies/page/1","","Movies English - newest"),
89
+                #("Movies English - top rated", "cinemalive::moviesenglish/toprated/page/1","","Movies English - top rated"),
90
+                #("Movies English - most watched", "cinemalive::moviesenglish/mostwatched/page/1","","Movies English - most watched"),
86
             ])
91
             ])
87
             r = self.call("moviesenglish")
92
             r = self.call("moviesenglish")
88
-            for item in re.findall(r'<li class="nav-submenu-item"><a href="/([\w/]+)">(.+?)</a></li>', r):
93
+            i0 = r.find('<div class="menu">')
94
+            result = re.findall(r'menu-item-4[23]\d+"><a href="([^"]+)">([^<]+)</a>', r[i0:])
95
+            for item in result:
89
                 title = "Movies English - "+item[1]
96
                 title = "Movies English - "+item[1]
90
-                data2 = item[0]+"/page/1"
97
+                data2 = item[0].replace("https://cinemalive.tv", "")  #+"lapa/1/"
98
+                data2 = data2[1:]
99
+                if not (data2.startswith("movie") or data2.startswith("genre")):continue
91
                 img = self.img
100
                 img = self.img
92
                 desc = title
101
                 desc = title
93
                 content.append((title,self.name+"::"+data2,img,desc))
102
                 content.append((title,self.name+"::"+data2,img,desc))
94
             return content
103
             return content
95
 
104
 
96
 
105
 
97
-        elif "search.php" in data:
106
+        elif clist == "" in data:
107
+            r = self.call(data)
108
+            result = re.findall("<article>(.+?)</article>", r)
109
+            for r2 in result:
110
+                m = re.search('<div class="title"><a href="https://cinemalive.tv/([^"]+)">(.+?)</a></div>', r2)
111
+                title = m.group(2)
112
+                data2 = m.group(1)
113
+                title = re.sub("<[^>]+>", "", title)
114
+                m = re.search('<img src="([^"]+)"', r2)
115
+                img = m.group(1).replace("-150x150", "-185x278") if m else ""
116
+                m = re.search(r'<span class="year">(\d+)</span>', r2)
117
+                year = m.group(1) if m else ""
118
+                if year:
119
+                    title = title + "(%s)" % year
120
+                m = re.search(r"url\(https://cinemalive\.tv/static_main/assets/img/flags/(\w+)\.png\)", r2)
121
+                flag = m.group(1) if m else ""
122
+                if flag:
123
+                    title = title + "[%s]" % flag
124
+                m = re.search('<div class="contenido"><p>([^<]+)</p>', r2)
125
+                desc = m.group(1) if m else ""
98
 
126
 
99
-            r=self.call(path,params=params[1:],headers=self.headers2)
100
-            result = re.findall(r'<div class="results.+?<a href="https://cinemalive\.tv/(.+?)">.+?<img src="(.+?)".+?<span style="color:#bcbcbc">([^<]+)</span> <span style="color:#5a606d;font-size:12px;">([^<]+)</span><br/>.+?<p class="dec" style="font-size:12px; color:#777;line-height:14px;">([^<]+)</p>', r, re.DOTALL)
101
-            for item in result:
102
-                title = item[2]
103
-                title0 = re.sub(" \(\d+\)","",title)
104
-                if title0 == item[3]:
105
-                    title = title+" [EN]"
106
-                else:
107
-                    title = title + "/"+ item[3]+" [LV]"
108
-                title = util.unescape(title)
109
-                data2 = item[0]
110
-                img = item[1].replace("xs.","sm.")
111
-                desc = util.unescape(item[4])
112
                 content.append((title,self.name+"::"+data2,img,desc))
127
                 content.append((title,self.name+"::"+data2,img,desc))
113
             return content
128
             return content
114
 
129
 
115
-        elif clist in ("filmaslatviski","moviesenglish"):
116
-            r = self.call(data)
117
-            if not r:
130
+        elif clist in ("filmaslatviski","moviesenglish", "genre"):
131
+            r0 = self.call(data)
132
+            if not r0:
118
                 return content
133
                 return content
119
-            result = re.findall(r'<div class="base-used">.+?<a href="https://cinemalive.tv/([^"]+)">.+?<img class="img-thumbnail" src="/([^"]+)" alt="([^"]+)"/>.+?<p class="year">(\d+)</p>', r, re.DOTALL)
120
-            for item in result:
121
-                title = item[2] + " (%s)"%item[3]
122
-                data2 = item[0]
123
-                img = "https://cinemalive.tv/"+item[1]
124
-                title = util.unescape(title)
125
-                desc = title
134
+            #result = re.findall(r'<div class="base-used">.+?<a href="https://cinemalive.tv/([^"]+)">.+?<img class="img-thumbnail" src="/([^"]+)" alt="([^"]+)"/>.+?<p class="year">(\d+)</p>', r, re.DOTALL)
135
+            result = re.findall('<article id="post.+?</article>', r0, re.IGNORECASE)
136
+            for r in result:
137
+                m = re.search('alt="([^"]+)"', r, re.IGNORECASE)
138
+                title = m.group(1)
139
+                m = re.search('class="quality">(.+?)</span>', r, re.IGNORECASE)
140
+                sub = " [%s]" % m.group(1) if m else ""
141
+                m = re.search(r"</h3><span>(\d+)</span>", r, re.IGNORECASE)
142
+                gads = " (%s)" % m.group(1) if m else ""
143
+                title = title + gads + sub
144
+                m = re.search('<h3><a href="https://cinemalive.tv/([^"]+)"', r, re.IGNORECASE)
145
+                data2 = m.group(1)
146
+                m = re.search('img src="([^"]+)"', r, re.IGNORECASE)
147
+                img = m.group(1) if m else ""
148
+                m = re.search('class="texto">([^<]+)<', r, re.IGNORECASE)
149
+                desc = m.group(1)
150
+                #TODO - papildus info no apraksta
126
                 content.append((title,self.name+"::"+data2,img,desc))
151
                 content.append((title,self.name+"::"+data2,img,desc))
127
-            m = re.search(r"""<a href='https://cinemalive\.tv/([^']+)' style="border-right:none;">»</a>""", r, re.DOTALL)
152
+            m = re.search(r"""<span class="current">\d+</span><a href='https://cinemalive.tv/([^']+)'""", r0)
128
             if m:
153
             if m:
129
                 data2 = m.group(1)
154
                 data2 = m.group(1)
130
                 content.append(("Next page",self.name+"::"+data2,self.img,"Next page"))
155
                 content.append(("Next page",self.name+"::"+data2,self.img,"Next page"))
150
         title0 = re.search("<title>([^<]+)</title>", r).group(1)
175
         title0 = re.search("<title>([^<]+)</title>", r).group(1)
151
         lang = "LV" if "Filma Online Latviski" in title0 else "EN"
176
         lang = "LV" if "Filma Online Latviski" in title0 else "EN"
152
         title = title0.replace(" - Filma Online Latviski","").replace(" - Movie Online English HD","")
177
         title = title0.replace(" - Filma Online Latviski","").replace(" - Movie Online English HD","")
153
-        desc = re.search('<p class="plot">(.+?)</p>', r).group(1)
154
-        img = "http://cinemalive.tv"+re.search('<img src="(.+?)" class="img-thumbnail"', r).group(1)
155
-
156
-        m = re.search(r'<video id=.+?<source src="([^"]+\.mp4)"', r, re.DOTALL)
178
+        m = re.search(' class="wp-content"><p>(.+?)</p>', r, re.IGNORECASE)
179
+        desc = m.group(1) if m else title
180
+        m = re.search('<div class="poster"><img src="([^"]+)"', r, re.IGNORECASE)
181
+        img = m.group(1) if m else ""
182
+
183
+        #              <iframe class="metaframe rptss" src="https://cloudsany.com/i/tqxkulkkcind"
184
+        m = re.search('<iframe class="metaframe rptss" src="([^"]+)"', r, re.IGNORECASE)
185
+        if not m:
186
+            raise Exception("Can not find stream")
187
+        url = m.group(1)
188
+        r = self._http_request(url)
189
+        m = re.search(r"'(https\|.+?jwplayer)'", r)
190
+        if not m:
191
+            raise Exception("Can not find stream")
192
+        p = m.group(1).split("|")
193
+        p0 = m.group(1)
194
+        m = re.search(r"(Latvian)\|label\|(srt)\|(jqfm2sqwar22)\|subtitles", p0)
157
         if m:
195
         if m:
158
-            s = util.item()
159
-            s["url"] = m.group(1)
160
-            s["name"] = util.unescape(title)
161
-            s["desc"] = util.unescape(desc)
162
-            s["img"] = img
163
-            s["type"] = self.stream_type(s["url"])
164
-            s["lang"] = lang
165
-            return [s]
166
-
167
-        #m = re.search('<div class="viboom-overroll"><iframe src="([^"]+)"', r)
168
-        #if m:
169
-        result = re.findall('<div id="video_container"><iframe.+?src="(.+?)"', r)
170
-        if result:
171
-            streams = resolve(result[0])
172
-            for s in streams:
173
-                s["name"] = util.unescape(title)
174
-                s["desc"] = util.unescape(desc)
175
-                s["img"] = img
176
-                s["type"] = self.stream_type(s["url"])
177
-                s["lang"] = lang
178
-            if len(result)>1:
179
-                lang2 = "EN" if lang=="LV" else "LV"
180
-                streams2 = resolve(result[1])
181
-                for s in streams2:
182
-                    s["name"] = util.unescape(title)
183
-                    s["desc"] = util.unescape(desc)
184
-                    s["img"] = img
185
-                    s["type"]= self.stream_type(s["url"])
186
-                    s["lang"] = lang2
187
-                    streams.append(s)
188
-            return streams
189
-        else:
190
-            return []
196
+            url_sub = "https://cloudsany.com/subtitles/%s.%s" % (m.group(3), m.group(2))
197
+            url_title = m.group(1)
198
+            print url_title
199
+        m = re.search(r"tracks\|(\w+)\|(\w+)\|(\w+)\|files\|(\w+)\|(\w+)\|(\w+)", p0)
200
+        if m:
201
+            #https://dl4.sanii.co/files/8/80mbh8zjyuh61n/video.mp4
202
+            # 0://1v.1u.1t/1s/2/1r/1q.1p
203
+            num = re.search(r"0://1\w\.1\w\.1\w/1\w/(\d+)", r).group(1)
204
+            url = "https://%s.%s.%s/files/%s/%s/%s.%s" % (
205
+                m.group(6), m.group(5), m.group(4), num, m.group(3), m.group(2), m.group(1))
206
+            print url
207
+            x = 1
208
+
209
+        s = util.item()
210
+        s["url"] = url
211
+        s["name"] = util.unescape(title)
212
+        s["desc"] = util.unescape(desc)
213
+        s["img"] = img
214
+        s["type"] = self.stream_type(s["url"])
215
+        s["lang"] = lang
216
+        return [s]
217
+
191
 
218
 
192
 
219
 
193
 if __name__ == "__main__":
220
 if __name__ == "__main__":

+ 74
- 33
sources/filmix.py View File

69
             ])
69
             ])
70
             return content
70
             return content
71
 
71
 
72
-        #elif clist=="search":
73
-            # TODO
74
-            #return content
72
+        elif clist=="search":
73
+            if len(plist) < 2:
74
+                return content
75
+            import requests
76
+            ses = requests.session()
77
+            r = ses.get(self.url+data)
78
+            url = "https://filmix.me/engine/ajax/sphinx_search.php"
79
+            headers = headers2dict("""
80
+                User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0
81
+                Content-Type: application/x-www-form-urlencoded; charset=UTF-8
82
+            """)
83
+            data = "scf=fx&story=%s&search_start=0&do=search&subaction=search" % (plist[1].replace(" ", "+"))
84
+            r = ses.post(url, data, headers=headers)
85
+            #r = r.content.decode("cp1251").encode("utf8")
86
+            content = self.process_list(r.content, content)
87
+            return content
75
 
88
 
76
         elif data in ("movies","series","cartoons"):
89
         elif data in ("movies","series","cartoons"):
77
             r = self.call("")
90
             r = self.call("")
91
+            if not r:
92
+                raise Exception("Can not read content")
78
             r = r.decode("cp1251").encode("utf8")
93
             r = r.decode("cp1251").encode("utf8")
79
             if data == "movies":
94
             if data == "movies":
80
                 sname = "Фильмы"
95
                 sname = "Фильмы"
154
         else:
169
         else:
155
             r = self.call(data)
170
             r = self.call(data)
156
             r = r.decode("cp1251").encode("utf8")
171
             r = r.decode("cp1251").encode("utf8")
157
-            for r2 in re.findall('<article class="shortstory line".+?</article>', r, re.DOTALL):
158
-                #m2 = re.search(r'<a class="watch icon-play" itemprop="url" href="([^"]+)"', r2, re.DOTALL)
159
-                #<a class="watch icon-play" itemprop="url" href="https://filmix.me/dramy/110957-stolik-19-2017.html"
160
-                #m = re.search(r'<a href="https://filmix\.me/play/(\d+)" class="watch icon-play">', r2, re.DOTALL)
161
-                m = re.search(r'<a class="watch icon-play" itemprop="url" href="https://filmix.me/\w+/(\d+)-', r2, re.DOTALL)
162
-                if not m: continue
163
-                vid = m.group(1)
164
-                data2 = "play/%s"%vid
165
-                #title = re.search('itemprop="name">([^<]+)</div>', r2, re.DOTALL).group(1)
166
-                title = re.search('itemprop="name" content="([^"]+)"', r2, re.DOTALL).group(1)
167
-                m = re.search('itemprop="alternativeHeadline" content="([^"]+)"', r2, re.DOTALL)
168
-                if m:
169
-                    title = title + "/"+m.group(1)
170
-                m = re.search('<img src="([^"]+..png)"', r2, re.DOTALL)
171
-                img = m.group(1) if m else self.img
172
-                m = re.search(r'<a itemprop="copyrightYear".+?>(\d+)<', r2, re.DOTALL)
173
-                if m:
174
-                    year = m.group(1) if m else ""
175
-                    title = "%s (%s)"%(title,year)
176
-                title = util.unescape(title)
177
-                genre = re.findall('<a itemprop="genre"[^>]+?">([^<]+)</a>', r2, re.DOTALL)
178
-                genre = ",".join(genre)
179
-                m = re.search('<p itemprop="description">([^<]+)</p>', r2, re.DOTALL)
180
-                desc0 = util.unescape(m.group(1)) if m else ""
181
-                m = re.search('<div class="quality">([^<]+)</div>', r2, re.DOTALL)
182
-                quality = m.group(1) if m else ""
183
-                actors = re.findall('itemprop="actor">([^<]+)<', r2, re.DOTALL)
184
-                actors = ",".join(actors)
185
-                desc="%s\n%s\n%s\n%s\n%s"%(title,genre,desc0,actors,quality)
186
-                content.append((title,self.name+"::"+data2,img,desc))
172
+            content = self.process_list(r, content)
187
             if '<div class="navigation">' in r:
173
             if '<div class="navigation">' in r:
188
                 m = re.search(r'href="https://filmix\.me/([^"]+)" class="next icon-arowRight btn-tooltip"', r, re.DOTALL)
174
                 m = re.search(r'href="https://filmix\.me/([^"]+)" class="next icon-arowRight btn-tooltip"', r, re.DOTALL)
189
                 if m:
175
                 if m:
199
 
185
 
200
             return content
186
             return content
201
 
187
 
188
+    def process_list(self, r, content):
189
+        for r2 in re.findall('<article class="shortstory line".+?</article>', r, re.DOTALL):
190
+            #m2 = re.search(r'<a class="watch icon-play" itemprop="url" href="([^"]+)"', r2, re.DOTALL)
191
+            #<a class="watch icon-play" itemprop="url" href="https://filmix.me/dramy/110957-stolik-19-2017.html"
192
+            #m = re.search(r'<a href="https://filmix\.me/play/(\d+)" class="watch icon-play">', r2, re.DOTALL)
193
+            m = re.search(r'<a class="watch icon-play" itemprop="url" href="https://filmix.me/\w+/(\d+)-', r2, re.DOTALL)
194
+            if not m: continue
195
+            vid = m.group(1)
196
+            data2 = "play/%s"%vid
197
+            #title = re.search('itemprop="name">([^<]+)</div>', r2, re.DOTALL).group(1)
198
+            title = re.search('itemprop="name" content="([^"]+)"', r2, re.DOTALL).group(1)
199
+            m = re.search('itemprop="alternativeHeadline" content="([^"]+)"', r2, re.DOTALL)
200
+            if m:
201
+                title = title + "/"+m.group(1)
202
+            m = re.search(r'img src="(https://filmix\.me/uploads/posters/thumbs/[^"]+)"', r2)
203
+            img = m.group(1) if m else self.img
204
+
205
+            m = re.search(r'<a itemprop="copyrightYear".+?>(\d+)<', r2, re.DOTALL)
206
+            if m:
207
+                title = "%s (%s)"%(title,m.group(1))
208
+            title = util.unescape(title)
209
+
210
+            m = re.search('<p itemprop="description">([^<]+)</p>', r2, re.DOTALL)
211
+            desc0 = util.unescape(m.group(1)) if m else ""
212
+
213
+            props = []
214
+            genre = re.findall('<a itemprop="genre"[^>]+?">([^<]+)</a>', r2, re.DOTALL)
215
+            genre = ",".join(genre)
216
+            if genre: props.append(genre)
217
+
218
+            m = re.search('<div class="quality">([^<]+)</div>', r2, re.DOTALL)
219
+            if m: props.append(m.group(1))
220
+
221
+            m = re.search('<div class="item translate".+?class="item-content">([^<]+)<', r2)
222
+            if m: props.append(m.group(1))
223
+
224
+            m = re.search('itemprop="director">([^<]+)</span></div>', r2)
225
+            if m: props.append(m.group(1))
226
+
227
+            m = re.search('<div class="item actors">(.+?)</div>', r2)
228
+            if m:
229
+                result = re.findall("<span>(.+?)(&nbsp;)*</span>", m.group(1))
230
+                if result:
231
+                    actors = []
232
+                    for a in zip(*result)[0]:
233
+                        actors.append(re.sub("<.+?>", "", a))
234
+                    props.append(" ".join(actors))
235
+                else:
236
+                    x = 1
237
+                    pass
238
+
239
+            desc="%s\n%s\n\n%s"%(title, desc0, "\n".join(props))
240
+            content.append((title,self.name+"::"+data2,img,desc))
241
+        return content
242
+
202
     def is_video(self,data):
243
     def is_video(self,data):
203
         source,data,path,plist,clist,params,qs = self.parse_data(data)
244
         source,data,path,plist,clist,params,qs = self.parse_data(data)
204
         if clist == "play" and "e=" in data:
245
         if clist == "play" and "e=" in data:

+ 13
- 15
sources/replay.py View File

9
     import json
9
     import json
10
 except:
10
 except:
11
     import simplejson as json
11
     import simplejson as json
12
-
12
+import os
13
 import urllib2, urllib
13
 import urllib2, urllib
14
 import datetime, re, sys
14
 import datetime, re, sys
15
 import ssl
15
 import ssl
129
             if veids == "video":
129
             if veids == "video":
130
                 m = re.search('<div class="video"><iframe.+src="([^"]+)"', r)
130
                 m = re.search('<div class="video"><iframe.+src="([^"]+)"', r)
131
                 if not m:
131
                 if not m:
132
-                    content=("No stream found %s"%data,"","","No stream found")
133
-                    return content
132
+                    raise Exception("No stream found")
134
                 url = m.group(1)
133
                 url = m.group(1)
135
                 headers = headers2dict("""
134
                 headers = headers2dict("""
136
             User-Agent: Mozilla/5.0 (Linux; U; Android 4.4.4; Nexus 5 Build/KTU84P) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
135
             User-Agent: Mozilla/5.0 (Linux; U; Android 4.4.4; Nexus 5 Build/KTU84P) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
138
                     """)
137
                     """)
139
                 r = self._http_request(url,headers=headers)
138
                 r = self._http_request(url,headers=headers)
140
 
139
 
141
-                m = re.search('<div class="video-player"><iframe.+src="([^"]+)"', r)
140
+                #m = re.search('<div class="video-player"><iframe.+src="([^"]+)"', r)
141
+                m = re.search(r'iframe src=\\"([^"]+)\\', r)
142
                 if not m:
142
                 if not m:
143
-                    content=("No stream found %s"%data,"","","No stream found")
144
-                    return content
145
-                url = m.group(1)
143
+                    raise Exception("No stream found")
144
+                url = m.group(1).replace('\\/', "/")
146
 
145
 
147
                 r = self._http_request(url,headers=headers)
146
                 r = self._http_request(url,headers=headers)
148
                 m = re.search('"([^"]+m3u8[^"]+)"', r)
147
                 m = re.search('"([^"]+m3u8[^"]+)"', r)
149
                 if not m:
148
                 if not m:
150
-                    content=("No stream found %s"%data,"","","No stream found")
151
-                    return content
149
+                    raise Exception("No stream found")
152
                 data2 = m.group(1).replace("\\","")
150
                 data2 = m.group(1).replace("\\","")
153
                 #r = self._http_request(data2, headers=headers)
151
                 #r = self._http_request(data2, headers=headers)
154
 
152
 
158
                 r = self._http_request(url)
156
                 r = self._http_request(url)
159
                 m = re.search('"file":"([^"]+?m3u8.*?)"', r)
157
                 m = re.search('"file":"([^"]+?m3u8.*?)"', r)
160
                 if not m:
158
                 if not m:
161
-                    content=("No stream found %s"%data,"","","No stream found")
162
-                    return content
159
+                    raise Exception("No stream found")
163
                 data2 = m.group(1).replace("\\","")
160
                 data2 = m.group(1).replace("\\","")
164
 
161
 
165
             img = ""
162
             img = ""
199
         elif clist in ( "raidijumi","peredachi"):
196
         elif clist in ( "raidijumi","peredachi"):
200
             for item in re.findall('<li itemprop="name"><a href="([^"]+)" itemprop="url">([^<]+)', r):
197
             for item in re.findall('<li itemprop="name"><a href="([^"]+)" itemprop="url">([^<]+)', r):
201
             #for item in re.findall('<li itemprop="name"><a href="([^"]+)" itemprop="url">([^<]+)</a></li>', r):
198
             #for item in re.findall('<li itemprop="name"><a href="([^"]+)" itemprop="url">([^<]+)</a></li>', r):
202
-                title = item[1]
199
+                title = item[1].strip()
203
                 data2 = item[0].replace("/%s/"%lang,"")+"?lang=%s"%lang
200
                 data2 = item[0].replace("/%s/"%lang,"")+"?lang=%s"%lang
204
                 img = ""
201
                 img = ""
205
                 desc  = ""
202
                 desc  = ""
208
         ### Raidijuma ieraksti speciālie###
205
         ### Raidijuma ieraksti speciālie###
209
         elif clist in ( "visi","vse",):
206
         elif clist in ( "visi","vse",):
210
             for item in re.findall('(?i)<figure><a href="([^"]+)" itemprop="image" data-image="([^"]+)".+class="thumbnail__duration">([^<]+)</time></figure><figcaption><h4 itemprop="about"><a href="[^"]+">([^<]+)</a></h4>.+>([^<]+).*</h5>.+>([^<]+)</time></figcaption>', r):
207
             for item in re.findall('(?i)<figure><a href="([^"]+)" itemprop="image" data-image="([^"]+)".+class="thumbnail__duration">([^<]+)</time></figure><figcaption><h4 itemprop="about"><a href="[^"]+">([^<]+)</a></h4>.+>([^<]+).*</h5>.+>([^<]+)</time></figcaption>', r):
211
-                title = item[3]
208
+                title = item[3].strip()
212
                 data2 = item[0].replace("/%s/"%lang,"")+"?lang=%s"%lang
209
                 data2 = item[0].replace("/%s/"%lang,"")+"?lang=%s"%lang
213
                 img = item[1].replace("https:","http:")
210
                 img = item[1].replace("https:","http:")
214
                 desc  = "%s - %s\n%s"%(item[5],item[2],item[4])
211
                 desc  = "%s - %s\n%s"%(item[5],item[2],item[4])
217
         ### Raidijuma ieraksti (videos)
214
         ### Raidijuma ieraksti (videos)
218
         elif clist in ("raidijums","peredacha","kategorija"):
215
         elif clist in ("raidijums","peredacha","kategorija"):
219
             for item in re.findall('<article .+ href="([^"]+)".+image="([^"]+)".+class="thumbnail__duration">([^<]+).+">([^<]+).+class="thumbnail__date ">([^"]+)</time></figcaption></article>', r):
216
             for item in re.findall('<article .+ href="([^"]+)".+image="([^"]+)".+class="thumbnail__duration">([^<]+).+">([^<]+).+class="thumbnail__date ">([^"]+)</time></figcaption></article>', r):
220
-                title = item[3]
217
+                title = item[3].strip()
221
                 data2 = item[0].replace("/%s/"%lang,"")+"?lang=%s"%lang
218
                 data2 = item[0].replace("/%s/"%lang,"")+"?lang=%s"%lang
222
                 img = item[1].replace("https:","http:")
219
                 img = item[1].replace("https:","http:")
223
                 desc = "%s - %s"%(item[4],item[2])
220
                 desc = "%s - %s"%(item[4],item[2])
221
+                desc = desc.strip()
224
                 content.append((title,self.name+"::"+data2,img,desc))
222
                 content.append((title,self.name+"::"+data2,img,desc))
225
 
223
 
226
         ### Ieraksts (video) ###
224
         ### Ieraksts (video) ###
237
                 if m:
235
                 if m:
238
                     data2 = m.group(1).replace("\\","")
236
                     data2 = m.group(1).replace("\\","")
239
                     m = re.search('"idstring":"([^"]+)', r2)
237
                     m = re.search('"idstring":"([^"]+)', r2)
240
-                    title = m.group(1) if m else ""
238
+                    title = m.group(1).strip() if m else ""
241
                     title = title.decode("unicode-escape").encode("utf8")
239
                     title = title.decode("unicode-escape").encode("utf8")
242
                     title = title.replace("\n","")
240
                     title = title.replace("\n","")
243
                     img = ""
241
                     img = ""

+ 13
- 14
sources/streams.cfg View File

27
 ..return|back|back.png|Atgriezties atpakaļ
27
 ..return|back|back.png|Atgriezties atpakaļ
28
 LTV1|replay::tiesraide/ltv1/|http://replay.lsm.lv/resources/logo/large_ltv1.png|LTV1 tiesraide (video )
28
 LTV1|replay::tiesraide/ltv1/|http://replay.lsm.lv/resources/logo/large_ltv1.png|LTV1 tiesraide (video )
29
 LTV7|replay::tiesraide/ltv7/|http://replay.lsm.lv/resources/logo/large_ltv7.png|LTV7 tiesraide (video )
29
 LTV7|replay::tiesraide/ltv7/|http://replay.lsm.lv/resources/logo/large_ltv7.png|LTV7 tiesraide (video )
30
-TVRiga24|play24::tiesraide|riga24.png|TVRiga24 live stream
31
-TVPlay Live|mtgplay::videos?country=lv&order=title&type=live|skaties.png|Skaties.lv live streams(not always available)
32
-LNT|ltc::content/live-streams/104?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_back.png/LNT_logo.png|LNT tiešraide (ltc)
33
-TV3|ltc::content/live-streams/103?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_back.png/TV3_logo.png|TV3 tiešraide (ltc)
34
-TV6 |ltc::content/live-streams/106?include=quality| https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/TV6_logo.png|TV6 tiešraide (ltc)
35
-3+|ltc::content/live-streams/107?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/3_logo.png|3+ tiešraide (ltc)
36
-Kanāls 2|ltc::content/live-streams/608?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/Kanals2_logo.png|Kanāls 2 tiešraide (ltc)
37
-360TV|ltc::content/live-streams/1051?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/360TV_new.png|360TV
38
-STV Pirmā!|ltc::content/live-streams/1069?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/STV.png|STV Pirmā! tiešraide (ltc)
39
-Re:TV|ltc::content/live-streams/924?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/RE_TV.png|Re:TV tiešraide (ltc)
40
-Euronews|euronews::live?lang=en|euronews.png|Euronews live stream
41
-TVDom live|tvdom::tiesraides|tvdom.png|RU live streams from TVDom
30
+TVRiga24|play24::tiesraide|riga24.png|TV live streams
31
+Re:TV|ltc::content/live-streams/924?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/RE_TV.png|Re:TV
32
+Skaties.lv Live|mtgplay::videos?country=lv&order=title&type=live|skaties.png|TV live streams(not always available)
33
+LNT|ltc::content/live-streams/104?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/LNT_logo.png|LNT (ltc)
34
+TV3|ltc::content/live-streams/103?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/TV3_logo.png|TV3 (ltc)
35
+Kanāls 2|ltc::content/live-streams/608?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/Kanals2_logo.png|Kanāls 2 (ltc)
36
+3+|ltc::content/live-streams/107?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/3_logo.png|3+ (ltc)
37
+360TV|ltc::content/live-streams/1051?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/360TV_new.png|360TV (ltc)
38
+STV Pirmā!|ltc::content/live-streams/1069?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/STV.png|STV Pirmā! (ltc)
39
+RU live|tvdom::tiesraides|tvdom.png|RU live streams from TVDom
40
+Euronews live|euronews::live?lang=en|euronews.png|Euronews live stream
42
 BBC live (iPlayer)|iplayer::live|iplayer.png|BBC live streams from iPlayer
41
 BBC live (iPlayer)|iplayer::live|iplayer.png|BBC live streams from iPlayer
43
 UK live (FilmOn) TV|filmon::group?id=5|https://static.filmon.com/assets/groups/5/big_logo.png|UK live streams from FilmOn
42
 UK live (FilmOn) TV|filmon::group?id=5|https://static.filmon.com/assets/groups/5/big_logo.png|UK live streams from FilmOn
44
 US live (USTVNow|ustvnow::tvlive|ustvnow.png|US live streams from FilmOn
43
 US live (USTVNow|ustvnow::tvlive|ustvnow.png|US live streams from FilmOn
47
 
46
 
48
 [my_archive]
47
 [my_archive]
49
 My Archive
48
 My Archive
50
-..return|back||Atgriezties atpakaļ
49
+..return|back|back.png|Atgriezties atpakaļ
51
 LTV arhīvs LV|replay::visi/jaunakie/?source=ltv&lang=lv|replay.png|LTV1, LTV2 pārraižu arhīvs LV
50
 LTV arhīvs LV|replay::visi/jaunakie/?source=ltv&lang=lv|replay.png|LTV1, LTV2 pārraižu arhīvs LV
52
 LTV arhīvs RU|replay::vse/novie/?source=ltv&lang=ru|replay.png|LTV1, LTV2 pārraižu arhīvs RU
51
 LTV arhīvs RU|replay::vse/novie/?source=ltv&lang=ru|replay.png|LTV1, LTV2 pārraižu arhīvs RU
53
 skaties.lv arhīvs|mtgplay::videos?country=lv&order=-airdate|skaties.png|MTG (LNT, TV3, TV6 u.c.) pārraižu arhīvs
52
 skaties.lv arhīvs|mtgplay::videos?country=lv&order=-airdate|skaties.png|MTG (LNT, TV3, TV6 u.c.) pārraižu arhīvs
60
 
59
 
61
 [my_video]
60
 [my_video]
62
 My Video
61
 My Video
63
-..return|back||Atgriezties atpakaļ
62
+..return|back|back.png|Atgriezties atpakaļ
64
 Filmix - Все фильмы|filmix::films|filmix.png|Все фильмы
63
 Filmix - Все фильмы|filmix::films|filmix.png|Все фильмы
65
 Filmix - Все сериалы|filmix::serialy|filmix.png|Все сериалы
64
 Filmix - Все сериалы|filmix::serialy|filmix.png|Все сериалы
66
 
65