Quellcode durchsuchen

Tkinter run u.c.

Ivars vor 7 Jahren
Ursprung
Commit
000d285dab
23 geänderte Dateien mit 1336 neuen und 1173 gelöschten Zeilen
  1. 4
    92
      ContentSources.py
  2. 664
    684
      project.wpr
  3. 505
    0
      run.py
  4. 1
    1
      sources/SourceBase.py
  5. 10
    10
      sources/cinemalive.py
  6. 11
    7
      sources/config.py
  7. 12
    12
      sources/euronews.py
  8. 9
    7
      sources/filmas.py
  9. 7
    23
      sources/filmix.py
  10. 7
    21
      sources/filmon.py
  11. 7
    39
      sources/iplayer.py
  12. 7
    21
      sources/lmt.py
  13. 14
    8
      sources/ltc.py
  14. 7
    21
      sources/movieplace.py
  15. 7
    21
      sources/mtgplay.py
  16. 7
    21
      sources/play24.py
  17. 7
    21
      sources/replay.py
  18. 7
    21
      sources/serialguru.py
  19. 21
    20
      sources/streams.cfg
  20. 9
    21
      sources/tvdom.py
  21. 7
    21
      sources/ustvnow.py
  22. 6
    18
      sources/viaplay.py
  23. 0
    63
      util.py

+ 4
- 92
ContentSources.py Datei anzeigen

@@ -20,7 +20,7 @@ class ContentSources(object):
20 20
     #----------------------------------------------------------------------
21 21
     def __init__(self, plugin_path):
22 22
         self.plugins = {}
23
-        self.error_content = [("..atpakaļ", "back", None, "Kļūda, atgriezties atpakaļ")]
23
+        self.error_content = [("..atpakaļ", "back", "back.png", "Kļūda, atgriezties atpakaļ")]
24 24
         sys.path.insert(0, plugin_path)
25 25
         #for f in os.listdir(plugin_path):
26 26
         #for f in next(os.walk(plugin_path))[2]:
@@ -165,100 +165,12 @@ class ContentSources(object):
165 165
         else:
166 166
             return None
167 167
 
168
-
169
-
170
-def run(data="config::home"):
171
-
172
-    sources = ContentSources("sources")
173
-    #options = sources.options_read("ltc")
174
-    #print options
175
-    history = []
176
-    cur = ("Home",data,None,None)
177
-    content = sources.get_content(cur[1])
178
-
179
-    exit_loop = False
180
-    while True:
181
-        print
182
-        for i,item in enumerate(content):
183
-            s = "%i: %s - %s %s"%(i,item[0],item[1],item[2])
184
-            print s #.encode(sys.stdout.encoding,"replace")
185
-
186
-        while True:
187
-            a = raw_input("Enter number, (-) for download, q for exit: ")
188
-            if a in ("q","Q","x","X"):
189
-                exit_loop = True
190
-                print "Exiting"
191
-                break
192
-            try:
193
-                n = int(a)
194
-                break
195
-            except:
196
-                print "Not number!"
197
-        if exit_loop: break
198
-        download = False
199
-        if n<0:
200
-            n = abs(n)
201
-            download = True
202
-        cur2 = content[n]
203
-        data0 = cur2[1].split("::")[1] if "::" in cur2[1] else cur2[1]
204
-        if not data0:
205
-            pass
206
-        elif cur2[1] == "back":
207
-            cur = history.pop()
208
-        elif sources.is_video(cur2[1]):
209
-            if sources.stream_type(cur2[1]):
210
-                stream = util.item()
211
-                stream["url"] = cur2[1]
212
-                stream["name"] = cur2[0]
213
-                streams = [stream]
214
-            else:
215
-                try:
216
-                    if not download:
217
-                        streams = sources.get_streams(cur2[1])
218
-                    else:
219
-                        stream = util.item()
220
-                        stream["url"] = cur2[1]
221
-                        stream["name"] = cur2[0]
222
-                        stream["url"] = util.streamproxy_encode2(stream["url"])
223
-                        print stream["url"]
224
-                        streams = [stream]
225
-                except Exception as e:
226
-                    print unicode(e)
227
-                    traceback.print_exc()
228
-                    streams = []
229
-            if streams:
230
-                if not download:
231
-                    util.play_video(streams)
232
-                else:
233
-                    #urlp = util.streamproxy_encode2(streams[0]["url"])
234
-                    #print urlp
235
-                    #util.player(urlp)
236
-                    #Downloader.download_video(streams)
237
-                    pass
238
-            else:
239
-                print "**No stream to play - %s "%(
240
-                    cur2[1])
241
-                raw_input("Press any key")
242
-            #import os
243
-            #os.system('"c:\Program Files (x86)\VideoLAN\VLC\vlc.exe" "%s"'%cur2[1])
244
-
245
-        else:
246
-            if "{0}" in cur2[1]:
247
-                a = raw_input("Enter value:")
248
-                cur2 = (cur2[0],cur2[1].format(a),cur2[2],cur2[3])
249
-            history.append(cur)
250
-            cur = cur2
251
-        try:
252
-            content = sources.get_content(cur[1])
253
-        except Exception as e:
254
-            print unicode(e)
255
-            traceback.print_exc()
256
-            raw_input("Continue?")
257
-
258 168
 if __name__ == "__main__":
169
+    from run import run
259 170
     show_hidden = False
260 171
     if len(sys.argv)>1:
261 172
         data= sys.argv[1]
262 173
     else:
263 174
         data = "config::home"
264
-    run(data)
175
+    sources = ContentSources("sources")
176
+    run(sources, data)

+ 664
- 684
project.wpr
Datei-Diff unterdrückt, da er zu groß ist
Datei anzeigen


+ 505
- 0
run.py Datei anzeigen

@@ -0,0 +1,505 @@
1
+#!/usr/bin/env python
2
+# coding=utf8
3
+import sys, os, traceback
4
+from Tkinter import *
5
+try:
6
+    from ttk import *
7
+except:
8
+    pass
9
+import tkMessageBox as tkm
10
+import tkSimpleDialog as tkd
11
+
12
+import PIL, StringIO
13
+from PIL import ImageTk, Image
14
+import requests, urllib2
15
+
16
+from ContentSources import ContentSources
17
+from sources.SourceBase import stream_type
18
+import util
19
+
20
+
21
+class Main(Frame):
22
+
23
+    def __init__(self, sources):
24
+        self.root = Tk()
25
+        self.root.geometry("1050x600")
26
+        Frame.__init__(self, self.root)
27
+        #self.pack()
28
+        self.pack(fill=BOTH, expand=1)
29
+        self.initUI()
30
+        items = ["item %s" % i for i in range(20)]
31
+        if sources:
32
+            self.sources = sources
33
+        else:
34
+            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
+        if not os.path.exists(self.tmp_path):
38
+            os.mkdir(self.tmp_path)
39
+        self.history = []
40
+        self.cur_index = 0
41
+        self.cur = ("Home", "config::home", "", "PlayStream home")
42
+
43
+    def initUI(self):
44
+        self.master.title("PlayStream")
45
+        self.txt1 = Label(self)
46
+        self.txt1.pack(side=TOP, fill=X, padx=15)
47
+        self.txt1.configure(font=("Tahoma", 14, "bold"))
48
+        self.txt1.config(text="")
49
+        self.txt2 = Label(self)
50
+        self.txt2.pack(side=TOP, fill=X, padx=15)
51
+        self.txt2.config(text="")
52
+        self.txt2.configure(font=("Tahoma", 12))
53
+
54
+        frame1 = Frame(self)
55
+        frame1.pack(side=TOP, fill=X, padx=15)
56
+        scrollbar = Scrollbar(frame1, orient=VERTICAL)
57
+        self.listbox = Listbox(frame1, width=80, height=30, yscrollcommand=scrollbar.set)
58
+        scrollbar.config(command=self.listbox.yview)
59
+        #self.listbox.config(yscrollcommand=scrollbar.set)
60
+        self.listbox.pack(side=LEFT)
61
+        scrollbar.pack(side=LEFT, fill=Y)
62
+        self.listbox.focus_set()
63
+        self.listbox.bind('<<ListboxSelect>>', lambda evt: self.list_action(evt, "Changed"))
64
+        self.listbox.bind('<Double-1> ', lambda evt:self.list_action(None, "Return"))
65
+        self.listbox.bind('<Key> ', self.list_action)
66
+
67
+        self.pic = Canvas(frame1, width=400, height=250)
68
+        self.pic.pack(side=TOP, expand=1)
69
+
70
+        frame2 = Frame(frame1, height=250, width=400)
71
+        frame2.pack(side=TOP)
72
+        scrollbar2 = Scrollbar(frame2)
73
+        self.desc = Text(frame2, height=15, width=70, wrap="word", yscrollcommand=scrollbar2.set)  #, borderwidth=0, highlightthickness=0)
74
+        scrollbar2.config(command=self.desc.yview)
75
+        scrollbar2.pack(side="right", fill="y")
76
+        self.desc.configure(font=("Tahoma", 10))
77
+        self.desc.pack(anchor=N)
78
+
79
+        frame3 = Frame(self, height=40)
80
+        frame3.pack(side=TOP, fill=X, padx=15)
81
+        self.b_select = Button(frame3, text="Select",
82
+                              command=lambda :self.list_action(None, "Return"), width=10)
83
+        self.b_select.pack(side=LEFT, anchor=S)
84
+
85
+        self.b_back = Button(frame3, text="Back",
86
+                                   command=lambda :self.list_action(None, "Escape"), width=10)
87
+        self.b_back.pack(side=LEFT, anchor=S)
88
+
89
+        self.b_options = Button(frame3, text="Options",
90
+                                 command=lambda :self.list_action(None, "Options"), width=10)
91
+        self.b_options.pack(side=LEFT, anchor=S)
92
+
93
+        self.b_config = Button(frame3, text="Config",
94
+                                 command=lambda :self.list_action(None, "Config"), width=10)
95
+        self.b_config.pack(side=LEFT, anchor=S)
96
+
97
+        self.b_exit = Button(frame3, text="Exit",
98
+                            command=self.quit, width=10)
99
+        self.b_exit.pack(side=LEFT, anchor=S)
100
+
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
+
116
+    def list_action(self, evt=None, key=None):
117
+        cs = int(self.listbox.curselection()[0])
118
+        self.cur_index = cs
119
+        if (not key) and evt:
120
+            w = evt.widget
121
+            value = w.get(cs)
122
+            key = evt.keysym
123
+        print 'Key %s' % (key)
124
+        data = self.content[cs][1]
125
+        cur2 = self.content[cs]
126
+
127
+        if key == "Changed":
128
+            self.show_desc()
129
+            self.show_pic()
130
+
131
+        elif key == "Return" and data <> "back":
132
+            if not self.sources.is_video(data):
133
+                if "{0}" in data:
134
+                    a = tkd.askstring("Search", "Search for")
135
+                    cur2 = (cur2[0],cur2[1].format(a),cur2[2],cur2[3])
136
+                self.history.append((self.cur, cs))
137
+                self.cur = self.content[cs]
138
+                self.cur_index = 0
139
+                try:
140
+                    self.show_content(cur2)
141
+                except Exception as e:
142
+                    print unicode(e)
143
+                    traceback.print_exc()
144
+                    tkm.showerror("Error getting content", unicode(e))
145
+                    prev = self.history.pop()
146
+                    self.cur = prev[0]
147
+                    self.cur_index = prev[1]
148
+                    self.show_content(self.cur, self.cur_index)
149
+                    return
150
+            else:
151
+                self.play_video(self.content[cs])
152
+                self.listbox.selection_set(self.cur_index)
153
+                self.listbox.activate(self.cur_index)
154
+                self.listbox.focus_set()
155
+
156
+        elif key == "BackSpace" or key == "Escape" or (key == "Return" and data == "back"):
157
+            if self.history:
158
+                prev = self.history.pop()
159
+                self.cur = prev[0]
160
+                self.cur_index = prev[1]
161
+                self.show_content(self.cur, self.cur_index)
162
+        elif key == "Right":
163
+            index2 = self.cur_index + 20
164
+            index2 = min(index2, self.listbox.index(END) - 1)
165
+            self.set_list_item(index2)
166
+
167
+        elif key == "Left":
168
+            index2 = self.cur_index - 20
169
+            index2 = max(index2, 0)
170
+            self.set_list_item(index2)
171
+
172
+    def set_list_item(self, index):
173
+        self.cur_index = index
174
+        self.listbox.selection_clear(0, END)
175
+        self.listbox.selection_set(index)
176
+        self.listbox.activate(index)
177
+        self.listbox.focus_set()
178
+        self.update()
179
+
180
+
181
+    def show_content(self, cur2, cur_index=0):
182
+        data = cur2[1]
183
+        self.txt1.config(text=cur2[0])
184
+        self.content = self.sources.get_content(data)
185
+        self.listbox.delete(0, END)
186
+        for item in self.content:
187
+            self.listbox.insert(END, item[0])
188
+        self.listbox.selection_set(cur_index)
189
+        self.listbox.activate(cur_index)
190
+        self.listbox.focus_set()
191
+        self.show_desc()
192
+        self.show_pic()
193
+
194
+    def show_desc(self):
195
+        cs = self.listbox.curselection()[0]
196
+        self.txt2.config(text=self.content[cs][0])
197
+        self.desc.config(state=NORMAL)
198
+        self.desc.delete("1.0", END)
199
+        self.desc.insert(END, self.content[cs][3])
200
+        self.desc.insert(END, "\n\n"+self.content[cs][2])
201
+        self.desc.config(state=DISABLED)
202
+
203
+    def show_pic(self):
204
+        cs = self.listbox.curselection()[0]
205
+        img = self.content[cs][2]
206
+        self.pic.delete(ALL)
207
+        if not img.startswith("http"):
208
+            img_path = os.path.join(self.picons_path, img)
209
+            if img and os.path.exists(img_path):
210
+                im =  Image.open(img_path)
211
+            else:
212
+                im = None
213
+        elif img:
214
+            fcache = img.replace(":", "_").replace("/", "-").replace(":", "_")
215
+            fcache = os.path.join(self.tmp_path, fcache)
216
+            if os.path.exists(fcache):
217
+                im =  Image.open(fcache)
218
+            else:
219
+                r = requests.get(img)
220
+                if r.status_code == 200:
221
+                    img_data = r.content
222
+                    im = Image.open(StringIO.StringIO(r.content))
223
+                    with open(fcache, "wb") as f:
224
+                        f.write(r.content)
225
+                else:
226
+                    im = None
227
+        if im:
228
+            im.thumbnail((400, 250))
229
+            image = ImageTk.PhotoImage(im)
230
+            imagesprite = self.pic.create_image(200, 125,image=image)
231
+            self.pic.image = image
232
+
233
+    def play_video(self, cur2):
234
+        if self.sources.stream_type(cur2[1]):
235
+            stream = util.item()
236
+            stream["url"] = cur2[1]
237
+            stream["name"] = cur2[0]
238
+            streams = [stream]
239
+        else:
240
+            try:
241
+                streams = self.sources.get_streams(cur2[1])
242
+            except Exception as e:
243
+                print unicode(e)
244
+                traceback.print_exc()
245
+                tkm.showerror("Error getting streams", unicode(e))
246
+                return
247
+            if not streams:
248
+                tkm.showerror("Error getting streams", "No streams found")
249
+                return
250
+            if len(streams) > 1:
251
+                lst = []
252
+                for i,s in enumerate(streams):
253
+                    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
255
+                stream = streams[a]
256
+            else:
257
+                stream = streams[0]
258
+            stream = util.stream_change(stream)
259
+            title = stream["name"] if not "nfo" in stream or not stream["nfo"] else util.nfo2title(stream["nfo"])
260
+            desc = stream["desc"] if not "nfo" in stream or not stream["nfo"] else util.nfo2desc(stream["nfo"])
261
+            img = stream["img"]
262
+            url = stream["url"]
263
+            suburl = ""
264
+            print url
265
+            if "subs" in stream and stream["subs"]:
266
+                suburl = stream["subs"][0]["url"]
267
+                print "\n**Download subtitles %s - %s"%(title,suburl)
268
+                subs = urllib2.urlopen(suburl).read()
269
+                if subs:
270
+                    fname0 = re.sub("[/\n\r\t,:\?]","_",title)
271
+                    subext = ".srt"
272
+                    subfile = os.path.join(self.tmp_path,fname0+subext)
273
+                    if ".xml" in suburl:
274
+                        subs = util.ttaf2srt(subs)
275
+                    with open(subfile,"w") as f:
276
+                        f.write(subs)
277
+                else:
278
+                    print "\n Error downloading subtitle %s"%suburl
279
+            print "\n**Play stream %s\n%s" % (title, url.encode("utf8"))
280
+            player(url,title,suburl,stream["headers"])
281
+
282
+
283
+
284
+    def start(self):
285
+        self.root.mainloop()
286
+
287
+
288
+class ChoiceBox(tkd.Dialog):
289
+    #a = ChoiceBox("ChoiceBox test", "Select stream", items, parent=self).result
290
+    def __init__(self, title, prompt, items, width=20, height=15,
291
+                 initialvalue=0, parent = None):
292
+        if not parent:
293
+            import Tkinter
294
+            parent = Tkinter._default_root
295
+        self.prompt = prompt
296
+        self.items = items
297
+        self.width = width
298
+        self.height = height
299
+        self.result = None
300
+        self.initialvalue = initialvalue
301
+        tkd.Dialog.__init__(self, parent, title)
302
+
303
+    def body(self, master):
304
+        w = Label(self, text=self.prompt, justify=LEFT)
305
+        w.pack(side=TOP)
306
+        frame1 = Frame(self)
307
+        frame1.pack(side=TOP, fill=X, expand=1, padx=5)
308
+        scrollbar = Scrollbar(frame1, orient=VERTICAL)
309
+        self.listbox = Listbox(frame1, yscrollcommand=scrollbar.set, width=self.width, height=self.height)
310
+        scrollbar.config(command=self.listbox.yview)
311
+        #self.listbox.config(yscrollcommand=scrollbar.set)
312
+        self.listbox.pack(side=LEFT, fill=BOTH, expand=1)
313
+        scrollbar.pack(side=LEFT, fill=Y)
314
+        for item in self.items:
315
+            self.listbox.insert(END, item)
316
+        self.listbox.selection_set(self.initialvalue)
317
+        self.listbox.activate(self.initialvalue)
318
+        self.listbox.bind('<Double-1> ', self.list_select)
319
+        self.listbox.bind('<Key> ', self.list_key)
320
+        self.update()
321
+        self.geometry("+%d+%d"%(self.parent.winfo_rootx()+100, self.parent.winfo_rooty()+100 ))
322
+        return self.listbox
323
+
324
+    def list_key(self, evt):
325
+        key = evt.keysym
326
+        #print 'Key %s' % (key)
327
+        if key == "Return":
328
+            self.ok()
329
+        elif key == "Escape":
330
+            self.cancel()
331
+
332
+    def list_select(self, evt):
333
+        self.ok()
334
+
335
+    def apply(self):
336
+        self.result = self.listbox.curselection()[0]
337
+
338
+
339
+def run(sources=None, data="config::home", title="Home"):
340
+    app = Main(sources)
341
+    app.show_content((title, data, "", ""))
342
+    app.start()
343
+
344
+
345
+
346
+def run_cli(sources, data="config::home"):
347
+
348
+    #options = sources.options_read("ltc")
349
+    #print options
350
+    history = []
351
+    cur = ("Home",data,None,None)
352
+    content = sources.get_content(cur[1])
353
+
354
+    exit_loop = False
355
+    while True:
356
+        print
357
+        for i,item in enumerate(content):
358
+            s = "%i: %s - %s %s"%(i,item[0],item[1],item[2])
359
+            print s #.encode(sys.stdout.encoding,"replace")
360
+
361
+        while True:
362
+            a = raw_input("Enter number, (-) for download, q for exit: ")
363
+            if a in ("q","Q","x","X"):
364
+                exit_loop = True
365
+                print "Exiting"
366
+                break
367
+            try:
368
+                n = int(a)
369
+                break
370
+            except:
371
+                print "Not number!"
372
+        if exit_loop: break
373
+        download = False
374
+        if n<0:
375
+            n = abs(n)
376
+            download = True
377
+        cur2 = content[n]
378
+        data0 = cur2[1].split("::")[1] if "::" in cur2[1] else cur2[1]
379
+        if not data0:
380
+            pass
381
+        elif cur2[1] == "back":
382
+            cur = history.pop()
383
+        elif sources.is_video(cur2[1]):
384
+            if sources.stream_type(cur2[1]):
385
+                stream = util.item()
386
+                stream["url"] = cur2[1]
387
+                stream["name"] = cur2[0]
388
+                streams = [stream]
389
+            else:
390
+                try:
391
+                    if not download:
392
+                        streams = sources.get_streams(cur2[1])
393
+                    else:
394
+                        stream = util.item()
395
+                        stream["url"] = cur2[1]
396
+                        stream["name"] = cur2[0]
397
+                        stream["url"] = util.streamproxy_encode2(stream["url"])
398
+                        print stream["url"]
399
+                        streams = [stream]
400
+                except Exception as e:
401
+                    print unicode(e)
402
+                    traceback.print_exc()
403
+                    streams = []
404
+            if streams:
405
+                if not download:
406
+                    play_video(streams)
407
+                else:
408
+                    #urlp = util.streamproxy_encode2(streams[0]["url"])
409
+                    #print urlp
410
+                    #util.player(urlp)
411
+                    #Downloader.download_video(streams)
412
+                    pass
413
+            else:
414
+                print "**No stream to play - %s "%(
415
+                    cur2[1])
416
+                raw_input("Press any key")
417
+            #import os
418
+            #os.system('"c:\Program Files (x86)\VideoLAN\VLC\vlc.exe" "%s"'%cur2[1])
419
+
420
+        else:
421
+            if "{0}" in cur2[1]:
422
+                a = raw_input("Enter value:")
423
+                cur2 = (cur2[0],cur2[1].format(a),cur2[2],cur2[3])
424
+            history.append(cur)
425
+            cur = cur2
426
+        try:
427
+            content = sources.get_content(cur[1])
428
+        except Exception as e:
429
+            print unicode(e)
430
+            traceback.print_exc()
431
+            raw_input("Continue?")
432
+
433
+def play_video(streams, select=False):
434
+    if len(streams)>1 and select:
435
+        for i,s in enumerate(streams):
436
+
437
+            print "%s: [%s,%s,%s] %s"%(i,s["quality"],s["lang"],s["type"],s["name"])
438
+        a = raw_input("Select stram to play: ")
439
+        try:
440
+            n = int(a)
441
+        except:
442
+            n = 0
443
+        if n>=len(streams):
444
+            stream = streams[-1]
445
+        else:
446
+            stream = streams[n]
447
+    else:
448
+        stream = streams[0]
449
+
450
+    stream = util.stream_change(stream)
451
+    title = stream["name"] if not "nfo" in stream or not stream["nfo"] else util.nfo2title(stream["nfo"])
452
+    desc = stream["desc"] if not "nfo" in stream or not stream["nfo"] else util.nfo2desc(stream["nfo"])
453
+    img = stream["img"]
454
+    url = stream["url"]
455
+    suburl = ""
456
+    print url
457
+    if "subs" in stream and stream["subs"]:
458
+        suburl = stream["subs"][0]["url"]
459
+        print "\n**Download subtitles %s - %s"%(title,suburl)
460
+        subs = urllib2.urlopen(suburl).read()
461
+        if subs:
462
+            fname0 = re.sub("[/\n\r\t,:\?]","_",title)
463
+            subext = ".srt"
464
+            subfile = os.path.join("",fname0+subext)
465
+            if ".xml" in suburl:
466
+                subs = ttaf2srt(subs)
467
+            with open(subfile,"w") as f:
468
+                f.write(subs)
469
+        else:
470
+            print "\n Error downloading subtitle %s"%suburl
471
+    print "\n**Play stream %s\n%s" % (title, url.encode("utf8"))
472
+    return player(url,title,suburl,stream["headers"])
473
+
474
+def player(url, title = "", suburl= "",headers={}):
475
+    from subprocess import call
476
+    cmd1 = [r"c:\Program Files\VideoLAN\VLC\vlc.exe",url,
477
+           "--meta-title",title.decode("utf8").encode(sys.getfilesystemencoding()),
478
+           "--http-user-agent","Enigma2"
479
+    ]
480
+    # gst-launch-1.0 -v souphttpsrc ssl-strict=false proxy=127.0.0.1:8888 extra-headers="Origin:adadadasd"  location="http://bitdash-a.akamaihd.net/content/sintel/sintel.mpd" ! decodebin! autovideosink
481
+    cmd2 = [
482
+        r"C:\gstreamer\1.0\x86_64\bin\gst-launch-1.0","-v",
483
+        "playbin", 'uri="%s"'%url,
484
+        #"souphttpsrc", "ssl-strict=false",
485
+        #"proxy=127.0.0.1:8888",
486
+        #'location="%s"'%url,
487
+        #'!decodebin!autovideosink'
488
+    ]
489
+    cmd3 = ["ffplay.exe",url]
490
+    cmd = cmd3 if url.startswith("https") else cmd2
491
+    ret = call(cmd)
492
+    #if ret:
493
+        #a = raw_input("*** Error, continue")
494
+    return
495
+
496
+
497
+if __name__ == "__main__":
498
+    show_hidden = False
499
+    if len(sys.argv)>1:
500
+        data= sys.argv[1]
501
+    else:
502
+        data = "config::home"
503
+    #sources = ContentSources("sources")
504
+    sources = None
505
+    run(sources, data)

+ 1
- 1
sources/SourceBase.py Datei anzeigen

@@ -54,7 +54,7 @@ User-Agent: Mozilla/5.0 (Linux; U; Android 4.4.4; Nexus 5 Build/KTU84P) AppleWeb
54 54
 
55 55
     def get_content(self,data):
56 56
         ### To be overriden in child class
57
-        return [("..atpakaļ","back",None,"Kļūda, atgriezties atpakaļ")]
57
+        return [("..atpakaļ","back","back.png","Kļūda, atgriezties atpakaļ")]
58 58
 
59 59
     def is_video(self,data):
60 60
         ### To be overriden in child class

+ 10
- 10
sources/cinemalive.py Datei anzeigen

@@ -55,7 +55,7 @@ Accept-Language: en-US,en;q=0.8
55 55
         print "[cinemalive] get_content:", data
56 56
         source,data,path,plist,clist,params,qs = self.parse_data(data)
57 57
         content=[]
58
-        content.append(("..return", "back","","Return back"))
58
+        content.append(("..return", "back","back.png","Return back"))
59 59
 
60 60
         if clist=="home":
61 61
             content.extend([
@@ -191,15 +191,15 @@ Accept-Language: en-US,en;q=0.8
191 191
 
192 192
 
193 193
 if __name__ == "__main__":
194
-    country= "lv"
195
-    c = Source(country)
196
-    if len(sys.argv)>1:
197
-        data= sys.argv[1]
198
-    else:
199
-        data = "home"
200
-    content = c.get_content(data)
201
-    for item in content:
202
-        print item
194
+
195
+    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
196
+    import run
197
+    source = Source()
198
+    data= sys.argv[1] if len(sys.argv)>1 else source.name+"::home"
199
+    run.run(source, data)
200
+    sys.exit()
201
+
202
+
203 203
     #cat = api.get_categories(country)
204 204
     #chan = api.get_channels("lv")
205 205
     #prog = api.get_programs(channel=6400)

+ 11
- 7
sources/config.py Datei anzeigen

@@ -98,18 +98,22 @@ class Source(SourceBase):
98 98
 
99 99
 
100 100
 if __name__ == "__main__":
101
-    c = Source()
102
-    content = c.get_content("home")
103
-    for item in content: print item
101
+    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
102
+    import run
103
+    source = Source()
104
+    data= sys.argv[1] if len(sys.argv)>1 else source.name+"::home"
105
+    run.run(source, data)
106
+    sys.exit()
107
+
104 108
     #c.del_item("home",0)
105 109
     #c.del_list("favorites")
106 110
 
107 111
     #c.add_item("home",("My Streams","config::favorites","","Mani saglabātie TV kanāli un video"),0)
108
-    c.replace_item("home",("My Streams","config::my_streams","default","Mani saglabātie TV kanāli un video"),0)
112
+    #c.replace_item("home",("My Streams","config::my_streams","default","Mani saglabātie TV kanāli un video"),0)
109 113
     #c.add_list("favorites")
110
-    #c.add_item("favorites",("..return","back","","Atgriezties atpakaļ"))
114
+    #c.add_item("favorites",("..return","back","back.png","Atgriezties atpakaļ"))
111 115
     #c.add_item("favorites",("LTV1","http://streamltv.cloudy.services/ltv/LTV02.smil/playlist.m3u8","picons/latvia1.png", "Latvijas televīzijas 1.kanāls"))
112 116
 
113
-    c.write_streams()
114
-    for item in content: print item
117
+    #c.write_streams()
118
+    #for item in content: print item
115 119
 

+ 12
- 12
sources/euronews.py Datei anzeigen

@@ -61,7 +61,7 @@ Connection: keep-alive
61 61
             raise Exception("Not valid default language - '%s'"%lang)
62 62
 
63 63
         content=[]
64
-        content.append(("..return", "back","","Return back"))
64
+        content.append(("..return", "back","back.png","Return back"))
65 65
 
66 66
         if clist=="home":
67 67
             content.extend([
@@ -127,7 +127,7 @@ Connection: keep-alive
127 127
                     ptitle = article["pTitle"] if "pTitle" in article else ""
128 128
                     id = article["id"]
129 129
                     desc = "%s\n%s\n%s %s"%(title,atime,vert,ptitle)
130
-                    img = "http://static.euronews.com/articles/%s/399x225_%s..png"%(id,id)
130
+                    img = "http://static.euronews.com/articles/%s/399x225_%s.png"%(id,id)
131 131
                     if not atype in ("breakingnews","wire"):
132 132
                         data2 = "content/getArticle?lang=%s&id=%s"%(lang,id)
133 133
                     else:
@@ -293,13 +293,13 @@ content-disposition: form-data; name=request
293 293
 if __name__ == "__main__":
294 294
     language= "en"
295 295
     c = Source(language)
296
-    data = '{"methodName":"content.getTimeline","apiKey":"androidPhoneEuronews-1.0","params":{"page":"1","byPage":"30"},"language":"en"}'
297
-    r = c.call(data)
298
-    if len(sys.argv)>1:
299
-        data= sys.argv[1]
300
-    else:
301
-        data = "home"
302
-    content = c.get_content(data)
303
-    for item in content:
304
-        print item
305
-    pass
296
+    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
297
+    import run
298
+    source = Source(language)
299
+    data= sys.argv[1] if len(sys.argv)>1 else source.name+"::home"
300
+    run.run(source, data)
301
+    sys.exit()
302
+
303
+    #c = Source(language)
304
+    #data = '{"methodName":"content.getTimeline","apiKey":"androidPhoneEuronews-1.0","params":{"page":"1","byPage":"30"},"language":"en"}'
305
+    #r = c.call(data)

+ 9
- 7
sources/filmas.py Datei anzeigen

@@ -61,7 +61,7 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
61 61
         print "[filmas] get_content:", data
62 62
         source, data, path, plist, clist, params, qs = self.parse_data(data)
63 63
         content = []
64
-        content.append(("..return", "back","","Return back"))
64
+        content.append(("..return", "back","back.png","Return back"))
65 65
 
66 66
         if clist=="home":
67 67
             content.extend([
@@ -70,7 +70,7 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
70 70
                 ("Spēlfilmas", "filmas::filmu-katalogs/?tab=movies&sub_tab=movies-view-2&mp20=112","","Visur skatamās spēlfilmas"),
71 71
                 ("Animācijas filmas", "filmas::filmu-katalogs/?tab=movies&sub_tab=movies-view-2&mp20=113","","Visur skatamās animācijas filmas"),
72 72
                 ("Dokumentalās filmas", "filmas::filmu-katalogs/?tab=movies&sub_tab=movies-view-2&mp20=111","","Visur skatamās dokumentalās filmas"),
73
-                 ("Kinohronikas", "filmas::filmu-katalogs/?tab=movies&sub_tab=movies-view-2&mp20=150","","Visur skatamās kinohronikas")    ,
73
+                ("Kinohronikas", "filmas::filmu-katalogs/?tab=movies&sub_tab=movies-view-2&mp20=150","","Visur skatamās kinohronikas")    ,
74 74
             ])
75 75
             return content
76 76
 
@@ -229,8 +229,10 @@ if __name__ == "__main__":
229 229
         #for s in streams:
230 230
         s = streams[0]
231 231
         download_hls(s["url"],"%s %s"%(s["name"],s["quality"]),"",s["headers"])
232
-    else:
233
-        content  = c.get_content(data)
234
-        for item in content:
235
-            print item
236
-    pass
232
+        sys.exit()
233
+    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
234
+    import run
235
+    source = Source()
236
+    data= sys.argv[1] if len(sys.argv)>1 else source.name+"::home"
237
+    run.run(source, data)
238
+    sys.exit()

+ 7
- 23
sources/filmix.py Datei anzeigen

@@ -58,7 +58,7 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
58 58
         print "[filmix] get_content:", data
59 59
         source, data, path, plist, clist, params, qs = self.parse_data(data)
60 60
         content=[]
61
-        content.append(("..return", "back","","Return back"))
61
+        content.append(("..return", "back","back.png","Return back"))
62 62
 
63 63
         if clist=="home":
64 64
             content.extend([
@@ -388,25 +388,9 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
388 388
 
389 389
 if __name__ == "__main__":
390 390
 
391
-    c = Source()
392
-    #s = "ZnVuY3Rpb24gc2VuZE1lc3NhZ2U2MDc3ODkoZSl7dmFyIGg9bWdfd3M2MDc3ODkub25tZXNzYWdlOyBtZ193czYwNzc4OS5yZWFkeVN0YXRlPT1tZ193czYwNzc4OS5DTE9TRUQmJihtZ193czYwNzc4OT1uZXcgV2ViU29ja2V0KG1nX3dzNjA3Nzg5X2xvY2F0aW9uKSksbWdfd3M2MDc3ODkub25tZXNzYWdlPWgsd2FpdEZvclNvY2tldENvbm5lY3Rpb242MDc3ODkobWdfd3M2MDc3ODksZnVuY3Rpb24oKXttZ193czYwNzc4OS5zZW5kKGUpfSl9ZnVuY3Rpb24gd2FpdEZvclNvY2tldENvbm5lY3Rpb242MDc3ODkoZSx0KXtzZXRUaW1lb3V0KGZ1bmN0aW9uKCl7cmV0dXJuIDE9PT1lLnJlYWR5U3RhdGU/dm9pZChudWxsIT10JiZ0KCkpOnZvaWQgd2FpdEZvclNvY2tldENvbm5lY3Rpb242MDc3ODkoZSx0KX0sNSl9OyB2YXIgbWdfd3M2MDc3ODlfbG9jYXRpb24gPSAid3NzOi8vd3NwLm1hcmtldGdpZC5jb20vd3MiOyBtZ193czYwNzc4OSA9IG5ldyBXZWJTb2NrZXQobWdfd3M2MDc3ODlfbG9jYXRpb24pLCBtZ193czYwNzc4OS5vbm1lc3NhZ2UgPSBmdW5jdGlvbiAodCkge3Bvc3RNZXNzYWdlKHQuZGF0YSk7fSwgb25tZXNzYWdlID0gZnVuY3Rpb24oZSl7c2VuZE1lc3NhZ2U2MDc3ODkoZS5kYXRhKX0="
393
-
394
-    #txt = c.decode_uppod_text(s)
395
-    if len(sys.argv)>1:
396
-        data= sys.argv[1]
397
-    else:
398
-        data = "home"
399
-    content = c.get_content(data)
400
-    for item in content:
401
-        print item
402
-    #cat = api.get_categories(country)
403
-    #chan = api.get_channels("lv")
404
-    #prog = api.get_programs(channel=6400)
405
-    #prog = api.get_programs(category=55)
406
-    #seas = api.get_seasons(program=6453)
407
-    #str = api.get_streams(660243)
408
-    #res = api.get_videos(802)
409
-    #formats = api.getAllFormats()
410
-    #det = api.detailed("1516")
411
-    #vid = api.getVideos("13170")
412
-    pass
391
+    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
392
+    import run
393
+    source = Source()
394
+    data= sys.argv[1] if len(sys.argv)>1 else source.name+"::home"
395
+    run.run(source, data)
396
+    sys.exit()

+ 7
- 21
sources/filmon.py Datei anzeigen

@@ -63,7 +63,7 @@ class Source(SourceBase):
63 63
         #    self.session_key = js["session_key"]
64 64
 
65 65
         content=[]
66
-        content.append(("..return", "back","","Return back"))
66
+        content.append(("..return", "back","back.png","Return back"))
67 67
 
68 68
         if clist=="home":
69 69
             content.extend([
@@ -254,23 +254,9 @@ Connection: keep-alive
254 254
         return js
255 255
 
256 256
 if __name__ == "__main__":
257
-    country= "lv"
258
-    c = Source(country)
259
-    if len(sys.argv)>1:
260
-        data= sys.argv[1]
261
-    else:
262
-        data = "home"
263
-    content = c.get_content(data)
264
-    for item in content:
265
-        print item
266
-    #cat = api.get_categories(country)
267
-    #chan = api.get_channels("lv")
268
-    #prog = api.get_programs(channel=6400)
269
-    #prog = api.get_programs(category=55)
270
-    #seas = api.get_seasons(program=6453)
271
-    #str = api.get_streams(660243)
272
-    #res = api.get_videos(802)
273
-    #formats = api.getAllFormats()
274
-    #det = api.detailed("1516")
275
-    #vid = api.getVideos("13170")
276
-    pass
257
+    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
258
+    import run
259
+    source = Source()
260
+    data= sys.argv[1] if len(sys.argv)>1 else source.name+"::home"
261
+    run.run(source, data)
262
+    sys.exit()

+ 7
- 39
sources/iplayer.py Datei anzeigen

@@ -77,7 +77,7 @@ Connection: Keep-Alive
77 77
         #lang = qs["lang"] if "lang" in qs else self.country
78 78
 
79 79
         content=[]
80
-        content.append(("..return", "back","","Return back"))
80
+        content.append(("..return", "back","back.png","Return back"))
81 81
 
82 82
         ### Home ###
83 83
         if data=="home":
@@ -519,41 +519,9 @@ def gt(dt_str):
519 519
     return dt
520 520
 
521 521
 if __name__ == "__main__":
522
-    c = Source()
523
-    from subprocess import call
524
-    #ch = c.get_channels()
525
-    #c.get_epg_live("bbc_two_england")
526
-
527
-    if len(sys.argv)>1 and  not "iplayer::" in sys.argv[1]:
528
-
529
-        vid = sys.argv[1]
530
-        print "login - %s"%c.login("ivars777","xxx")
531
-        vid = "1069"
532
-        vid = "1462566072086"
533
-        channelid="101"
534
-        vid = "1350462656767"
535
-        #data = c.get_stream_url(vid,"vod")
536
-        #call([r"c:\Program Files\VideoLAN\VLC\vlc.exe",data["stream"]])
537
-        pass
538
-
539
-
540
-
541
-    else:
542
-        if len(sys.argv)>1:
543
-            data= sys.argv[1]
544
-        else:
545
-            data = "iplayer::home"
546
-        content = c.get_content(data)
547
-        for item in content:
548
-            print item
549
-        #cat = api.get_categories(country)
550
-        #chan = api.get_channels("lv")
551
-        #prog = api.get_programs(channel=6400)
552
-        #prog = api.get_programs(category=55)
553
-        #seas = api.get_seasons(program=6453)
554
-        #str = api.get_streams(660243)
555
-        #res = api.get_videos(802)
556
-        #formats = api.getAllFormats()
557
-        #det = api.detailed("1516")
558
-        #vid = api.getVideos("13170")
559
-        pass
522
+    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
523
+    import run
524
+    source = Source()
525
+    data= sys.argv[1] if len(sys.argv)>1 else source.name+"::home"
526
+    run.run(source, data)
527
+    sys.exit()

+ 7
- 21
sources/lmt.py Datei anzeigen

@@ -54,7 +54,7 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
54 54
         print "[lmt] get_content:", data
55 55
         source, data, path, plist, clist, params, qs = self.parse_data(data)
56 56
         content = []
57
-        content.append(("..return", "back","","Return back"))
57
+        content.append(("..return", "back","back.png","Return back"))
58 58
 
59 59
         if clist=="home":
60 60
             content.extend([
@@ -197,23 +197,9 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
197 197
 
198 198
 
199 199
 if __name__ == "__main__":
200
-    country= "lv"
201
-    c = Source(country)
202
-    if len(sys.argv)>1:
203
-        data= sys.argv[1]
204
-    else:
205
-        data = "home"
206
-    content = c.get_content(data)
207
-    for item in content:
208
-        print item
209
-    #cat = api.get_categories(country)
210
-    #chan = api.get_channels("lv")
211
-    #prog = api.get_programs(channel=6400)
212
-    #prog = api.get_programs(category=55)
213
-    #seas = api.get_seasons(program=6453)
214
-    #str = api.get_streams(660243)
215
-    #res = api.get_videos(802)
216
-    #formats = api.getAllFormats()
217
-    #det = api.detailed("1516")
218
-    #vid = api.getVideos("13170")
219
-    pass
200
+    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
201
+    import run
202
+    source = Source()
203
+    data= sys.argv[1] if len(sys.argv)>1 else source.name+"::home"
204
+    run.run(source, data)
205
+    sys.exit()

+ 14
- 8
sources/ltc.py Datei anzeigen

@@ -78,7 +78,7 @@ Accept-Language: en-US,en;q=0.8
78 78
         source, data, path, plist, clist, params, qs = self.parse_data(data)
79 79
 
80 80
         content=[]
81
-        content.append(("..return", "back","","Return back"))
81
+        content.append(("..return", "back","back.png","Return back"))
82 82
 
83 83
         if clist=="home":
84 84
             content.extend([
@@ -336,15 +336,15 @@ Accept-Language: en-US,en;q=0.8
336 336
 
337 337
             # Ir sezonas
338 338
             if m:
339
-                result = re.findall(r"""season_choice\('[^']*','[^']*','(\d+)','epizode','([^']*)','','(\d+)',0,0\)">([^<]+)<""", r)
339
+                result = re.findall(r"""season_choice\(.+?'epizode','([^']*)',[^,]+,'(\d+)',[^,]+,[^,]+\)">([^<]+)<""", r, re.MULTILINE)
340 340
                 if not result:
341 341
                     raise Exception("No seasons find!")
342
-                vid = result[0][1]
342
+                vid = result[0][0]
343 343
 
344 344
                 if not "season_nr" in qs:  # Sezonu saraksts
345 345
                     for s,it in enumerate(result):
346
-                        title = "%s - %s" % (raidijums, it[3])
347
-                        data2 = path+"?season_nr=%s"%(it[2])
346
+                        title = "%s - %s" % (raidijums, it[2])
347
+                        data2 = path+"?season_nr=%s"%(it[1])
348 348
                         img = img0
349 349
                         desc = title
350 350
                         content.append((title, self.name + "::" + data2, img, desc))
@@ -354,6 +354,8 @@ Accept-Language: en-US,en;q=0.8
354 354
                     if not "season_nr" in qs:
355 355
                         qs["season_nr"]="0"
356 356
                     # https://www.lattelecom.tv/api/episode-loader-design17/0?chunk_size=4&sorting=epizode&series_id=dora_the_explorer
357
+                    # https://www.lattelecom.tv/api/episode-loader-design17/3?chunk_size=4&sorting=epizode&series_id=dora_the_explorer&movie_id=10161&z360tv=&is_active_season=false HTTP/1.1
358
+                    # https://www.lattelecom.tv/api/episode-loader-design17/3?chunk_size=4&sorting=epizode&series_id=dora_the_explorer
357 359
                     url = "https://www.lattelecom.tv/api/episode-loader-design17/%s?chunk_size=4&sorting=epizode&series_id=%s" % (qs["season_nr"], vid)
358 360
                     r = self._http_request(url,headers=self.headers2)
359 361
                     try:
@@ -1039,11 +1041,15 @@ User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like
1039 1041
             return False
1040 1042
 
1041 1043
 if __name__ == "__main__":
1042
-    c = Source()
1043
-    from subprocess import call
1044
-    c.get_info2(sys.argv[1])
1044
+    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
1045
+    import run
1046
+    source = Source()
1047
+    data= sys.argv[1] if len(sys.argv)>1 else source.name+"::home"
1048
+    run.run(source, data)
1045 1049
     sys.exit()
1046 1050
 
1051
+    c.get_info2(sys.argv[1])
1052
+
1047 1053
     if len(sys.argv)>1 and  not "ltc::" in sys.argv[1]:
1048 1054
 
1049 1055
         vid = vid2 = sys.argv[1]

+ 7
- 21
sources/movieplace.py Datei anzeigen

@@ -56,7 +56,7 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
56 56
         print "[movieplace] get_content:", data
57 57
         source, data, path, plist, clist, params, qs = self.parse_data(data)
58 58
         content = []
59
-        content.append(("..return", "back","","Return back"))
59
+        content.append(("..return", "back","back.png","Return back"))
60 60
 
61 61
         if clist=="home":
62 62
             content.extend([
@@ -213,23 +213,9 @@ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
213 213
         return streams
214 214
 
215 215
 if __name__ == "__main__":
216
-    country= "lv"
217
-    c = Source(country)
218
-    if len(sys.argv)>1:
219
-        data= sys.argv[1]
220
-    else:
221
-        data = "home"
222
-    content = c.get_content(data)
223
-    for item in content:
224
-        print item
225
-    #cat = api.get_categories(country)
226
-    #chan = api.get_channels("lv")
227
-    #prog = api.get_programs(channel=6400)
228
-    #prog = api.get_programs(category=55)
229
-    #seas = api.get_seasons(program=6453)
230
-    #str = api.get_streams(660243)
231
-    #res = api.get_videos(802)
232
-    #formats = api.getAllFormats()
233
-    #det = api.detailed("1516")
234
-    #vid = api.getVideos("13170")
235
-    pass
216
+    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
217
+    import run
218
+    source = Source()
219
+    data= sys.argv[1] if len(sys.argv)>1 else source.name+"::home"
220
+    run.run(source, data)
221
+    sys.exit()

+ 7
- 21
sources/mtgplay.py Datei anzeigen

@@ -63,7 +63,7 @@ class Source(SourceBase):
63 63
             self.country = qs["country"] if "country" in qs else "lv"
64 64
 
65 65
         content=[]
66
-        content.append(("..return", "back","","Return back"))
66
+        content.append(("..return", "back","back.png","Return back"))
67 67
 
68 68
         if clist=="home":
69 69
             content.extend([
@@ -261,23 +261,9 @@ class Source(SourceBase):
261 261
             return content
262 262
 
263 263
 if __name__ == "__main__":
264
-    country= "lv"
265
-    c = Source(country)
266
-    if len(sys.argv)>1:
267
-        data= sys.argv[1]
268
-    else:
269
-        data = "home"
270
-    content = c.get_content(data)
271
-    for item in content:
272
-        print item
273
-    #cat = api.get_categories(country)
274
-    #chan = api.get_channels("lv")
275
-    #prog = api.get_programs(channel=6400)
276
-    #prog = api.get_programs(category=55)
277
-    #seas = api.get_seasons(program=6453)
278
-    #str = api.get_streams(660243)
279
-    #res = api.get_videos(802)
280
-    #formats = api.getAllFormats()
281
-    #det = api.detailed("1516")
282
-    #vid = api.getVideos("13170")
283
-    pass
264
+    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
265
+    import run
266
+    source = Source()
267
+    data= sys.argv[1] if len(sys.argv)>1 else source.name+"::home"
268
+    run.run(source, data)
269
+    sys.exit()

+ 7
- 21
sources/play24.py Datei anzeigen

@@ -46,7 +46,7 @@ class Source(SourceBase):
46 46
         lang = qs["lang"] if "lang" in qs else self.country
47 47
 
48 48
         content=[]
49
-        content.append(("..return", "back","","Return back"))
49
+        content.append(("..return", "back","back.png","Return back"))
50 50
 
51 51
         if clist=="home":
52 52
             content.extend([
@@ -193,23 +193,9 @@ class Source(SourceBase):
193 193
         return content
194 194
 
195 195
 if __name__ == "__main__":
196
-    country= "lv"
197
-    c = Source(country)
198
-    if len(sys.argv)>1:
199
-        data= sys.argv[1]
200
-    else:
201
-        data = "home"
202
-    content = c.get_content(data)
203
-    for item in content:
204
-        print item
205
-    #cat = api.get_categories(country)
206
-    #chan = api.get_channels("lv")
207
-    #prog = api.get_programs(channel=6400)
208
-    #prog = api.get_programs(category=55)
209
-    #seas = api.get_seasons(program=6453)
210
-    #str = api.get_streams(660243)
211
-    #res = api.get_videos(802)
212
-    #formats = api.getAllFormats()
213
-    #det = api.detailed("1516")
214
-    #vid = api.getVideos("13170")
215
-    pass
196
+    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
197
+    import run
198
+    source = Source()
199
+    data= sys.argv[1] if len(sys.argv)>1 else source.name+"::home"
200
+    run.run(source, data)
201
+    sys.exit()

+ 7
- 21
sources/replay.py Datei anzeigen

@@ -50,7 +50,7 @@ class Source(SourceBase):
50 50
         lang = qs["lang"] if "lang" in qs else self.country
51 51
 
52 52
         content=[]
53
-        content.append(("..return", "back","","Return back"))
53
+        content.append(("..return", "back","back.png","Return back"))
54 54
 
55 55
         if clist=="home":
56 56
             content.extend([
@@ -288,23 +288,9 @@ Referer: http://replay.lsm.lv/lv/ieraksts/ltv/70398/tiesa-runa.-lielbritanija-ga
288 288
 
289 289
 
290 290
 if __name__ == "__main__":
291
-    country= "lv"
292
-    c = Source(country)
293
-    if len(sys.argv)>1:
294
-        data= sys.argv[1]
295
-    else:
296
-        data = "home"
297
-    content = c.get_content(data)
298
-    for item in content:
299
-        print item
300
-    #cat = api.get_categories(country)
301
-    #chan = api.get_channels("lv")
302
-    #prog = api.get_programs(channel=6400)
303
-    #prog = api.get_programs(category=55)
304
-    #seas = api.get_seasons(program=6453)
305
-    #str = api.get_streams(660243)
306
-    #res = api.get_videos(802)
307
-    #formats = api.getAllFormats()
308
-    #det = api.detailed("1516")
309
-    #vid = api.getVideos("13170")
310
-    pass
291
+    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
292
+    import run
293
+    source = Source()
294
+    data= sys.argv[1] if len(sys.argv)>1 else source.name+"::home"
295
+    run.run(source, data)
296
+    sys.exit()

+ 7
- 21
sources/serialguru.py Datei anzeigen

@@ -59,7 +59,7 @@ Referer: http://serialguru.ru/
59 59
         lang = qs["lang"] if "lang" in qs else self.country
60 60
 
61 61
         content=[]
62
-        content.append(("..return", "back","","Return back"))
62
+        content.append(("..return", "back","back.png","Return back"))
63 63
 
64 64
         if clist=="home":
65 65
             content.extend([
@@ -213,23 +213,9 @@ Referer: http://serialguru.ru/
213 213
         return content
214 214
 
215 215
 if __name__ == "__main__":
216
-    country= "lv"
217
-    c = Source(country)
218
-    if len(sys.argv)>1:
219
-        data= sys.argv[1]
220
-    else:
221
-        data = "home"
222
-    content = c.get_content(data)
223
-    for item in content:
224
-        print item
225
-    #cat = api.get_categories(country)
226
-    #chan = api.get_channels("lv")
227
-    #prog = api.get_programs(channel=6400)
228
-    #prog = api.get_programs(category=55)
229
-    #seas = api.get_seasons(program=6453)
230
-    #str = api.get_streams(660243)
231
-    #res = api.get_videos(802)
232
-    #formats = api.getAllFormats()
233
-    #det = api.detailed("1516")
234
-    #vid = api.getVideos("13170")
235
-    pass
216
+    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
217
+    import run
218
+    source = Source()
219
+    data= sys.argv[1] if len(sys.argv)>1 else source.name+"::home"
220
+    run.run(source, data)
221
+    sys.exit()

+ 21
- 20
sources/streams.cfg Datei anzeigen

@@ -4,7 +4,6 @@ My TV|config::my_tv|my_tv.png|Mani TV kanāli (tiešraide)
4 4
 My TV archive|config::my_archive|my_archive.png|Mani TV arhīvu video
5 5
 My Video|config::my_video|my_video.png|Mani video
6 6
 My Kids|config::my_kids|my_kids.png|Mani bērnu video
7
-#My Radio|config::my_radio|my_radio.png|Mani radio kanāli
8 7
 Replay.lv (LTV)|replay::home|replay.png|Latvijas TV tiešraides un arhīvs
9 8
 Skaties.lv (TV3)|mtgplay::home|skaties.png|MTG kanālu (LNT,TV3, TV6 u.c.) arhīvs
10 9
 Shortcut (lattelecom.tv)|ltc::home|shortcut.png|lattelecom TV, arhīves un video
@@ -25,19 +24,21 @@ TVPlay Baltic|config::mtg|tvplay.png|Other countries MTG media portals content
25 24
 
26 25
 [my_tv]
27 26
 My Tv
28
-..return|back|default|Atgriezties atpakaļ
27
+..return|back|back.png|Atgriezties atpakaļ
29 28
 LTV1|replay::tiesraide/ltv1/|http://replay.lsm.lv/resources/logo/large_ltv1.png|LTV1 tiesraide (video )
30 29
 LTV7|replay::tiesraide/ltv7/|http://replay.lsm.lv/resources/logo/large_ltv7.png|LTV7 tiesraide (video )
31
-TV3 (ltc)|ltc::content/live-streams/103?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/TV3_logo.png|TV3
32
-LNT (ltc)|ltc::content/live-streams/104?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/LNT_logo.png|LNT
33
-TV6|ltc::content/live-streams/106?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/TV6_logo.png|TV6
34
-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
35
-3+|ltc::content/live-streams/107?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/3_logo.png|3+
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)
36 37
 360TV|ltc::content/live-streams/1051?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/360TV_new.png|360TV
37
-STV Pirmā!|ltc::content/live-streams/1069?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/STV.png|STV Pirmā!
38
-TVRiga24|play24::tiesraide|riga.24.png|TV live streams
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
40
-RU live|tvdom::tiesraides|tvdom.png|RU live streams from TVDom
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
41 42
 BBC live (iPlayer)|iplayer::live|iplayer.png|BBC live streams from iPlayer
42 43
 UK live (FilmOn) TV|filmon::group?id=5|https://static.filmon.com/assets/groups/5/big_logo.png|UK live streams from FilmOn
43 44
 US live (USTVNow|ustvnow::tvlive|ustvnow.png|US live streams from FilmOn
@@ -54,18 +55,18 @@ Lattelecom.tv arhīvs - categories|ltc::archive/categories|shortcut.png|Lattelec
54 55
 TVRiga24 arhīvs|play24::kategorija/raidijumi|riga24.png|TVRiga24.tv pārraižu arhīvs
55 56
 TVDom arhīvs - categories|tvdom::arhivs|tvdom.png|TVDom(PBK, NTV, REN u.c.) pārraižu arhīvs RU
56 57
 BBC (iPlayer) arhīvs|iplayer::categories|iplayer.png|BBC programmes by categories
57
-Category - News|euronews::content/getVertical?lang=en&byPage=40&page=1&vId=1|euronews.png|Category - News
58
-Latest programs|euronews::content/getLatestPrograms?lang=en&byPage=40&page=1|euronews.png|Latest programs
58
+Euronews latest|euronews::content/getLatestPrograms?lang=en&byPage=40&page=1|euronews.png|Latest programs
59
+Euronews Categories|euronews::content/getVertical?lang=en&byPage=40&page=1&vId=1|euronews.png|Category - News
59 60
 
60 61
 [my_video]
61 62
 My Video
62 63
 ..return|back||Atgriezties atpakaļ
63
-Все фильмы|filmix::films|filmix.png|Все фильмы
64
-Все сериалы|filmix::serialy|filmix.png|Все сериалы
64
+Filmix - Все фильмы|filmix::films|filmix.png|Все фильмы
65
+Filmix - Все сериалы|filmix::serialy|filmix.png|Все сериалы
65 66
 
66 67
 [my_kids]
67 68
 My Kids
68
-..return|back|default|Atgriezties atpakaļ
69
+..return|back|back.png|Atgriezties atpakaļ
69 70
 Bērnu TV|config::my_kids_tv|my_tv.png|Bērnu TV kanāli
70 71
 Bērnu video|config::my_kids_video|my_video.png|Saglabātie bērnu video
71 72
 LTV bērnu TV arhīvs|replay::raidijumi/?lang=lv&type=video&theme=5|my_archive.png|LTV bērnu TV arhīvs
@@ -79,7 +80,7 @@ Filmix bērnu seriāli|filmix::detskij/s7|filmix.png|Filmix bērnu seriāli
79 80
 
80 81
 [my_kids_tv]
81 82
 My Kids TV
82
-..return|back|default|Atgriezties atpakaļ
83
+..return|back|back.png|Atgriezties atpakaļ
83 84
 Kidzone|ltc::content/live-streams/951?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/kidzone2_new.png|Kidzone
84 85
 Nickelodeon|ltc::content/live-streams/302?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/Nickelodeon.png|Nickelodeon
85 86
 Jim Jam|ltc::content/live-streams/303?include=quality|https://manstv.lattelecom.tv/images/01_Bildes/02_Kanalu_raidijumu_default/Jim_Jam.png|Jim Jam
@@ -92,11 +93,11 @@ Om Nom (FilmOn)|filmon::channel?id=3824|http://static.filmon.com/assets/channels
92 93
 
93 94
 [my_kids_video]
94 95
 My Kids Video
95
-..return|back|default|Atgriezties atpakaļ
96
+..return|back|back.png|Atgriezties atpakaļ
96 97
 
97 98
 [my_radio]
98 99
 My Radio
99
-..return|back|default|Atgriezties atpakaļ
100
+..return|back|back.png|Atgriezties atpakaļ
100 101
 LR1|replay::tiesraide/lr1/|http://replay.lsm.lv/resources/logo/lr1_logo.png|LR1 tiesraide (audio)
101 102
 LR2|replay::tiesraide/lr2/|http://replay.lsm.lv/resources/logo/lr2_logo.png|LR2 tiesraide (audio)
102 103
 LR3|replay::tiesraide/lr3/|http://replay.lsm.lv/resources/logo/lr3_logo.png|LR3 tiesraide (audio)
@@ -106,7 +107,7 @@ LR6|replay::tiesraide/lr6/|http://replay.lsm.lv/resources/logo/lr6_logo.png|LR6
106 107
 
107 108
 [mtg]
108 109
 MTG
109
-..return|back|default|Atgriezties atpakaļ
110
+..return|back|back.png|Atgriezties atpakaļ
110 111
 Estonia (tv3play.ee)|mtgplay::home?country=ee||MTG Estonia media portal content
111 112
 Lithuania (play.tv3.lt/)|mtgplay::home?country=lt||MTG Lithuania media portal content
112 113
 Sweden (tvXplay.se)|mtgplay::home?country=se||MTG Sweden media portal content

+ 9
- 21
sources/tvdom.py Datei anzeigen

@@ -88,7 +88,7 @@ Referer: https://tvdom.tv/
88 88
         lang = self.options["lang"]
89 89
         region = self.options["region"]
90 90
         content=[]
91
-        content.append(("..return", "back","","Return back"))
91
+        content.append(("..return", "back","back.png","Return back"))
92 92
 
93 93
         if clist=="home":
94 94
             content.extend([
@@ -293,6 +293,8 @@ Referer: https://tvdom.tv/
293 293
             if m:
294 294
                 data2 = m.group(1)
295 295
             else:
296
+                if "no_player_body" in r:
297
+                    raise Exception("Lai skatītos maksas kanālus, nepieciešams iegādāties abonementu")
296 298
                 raise Exception("No stream found")
297 299
             m = re.search('title: "([^"]+)"', r, re.DOTALL)
298 300
             title = m.group(1) if m else data2
@@ -323,23 +325,9 @@ Referer: https://tvdom.tv/
323 325
 
324 326
 
325 327
 if __name__ == "__main__":
326
-    country= "lv"
327
-    c = Source(country)
328
-    if len(sys.argv)>1:
329
-        data= sys.argv[1]
330
-    else:
331
-        data = "home"
332
-    content = c.get_content(data)
333
-    for item in content:
334
-        print item
335
-    #cat = api.get_categories(country)
336
-    #chan = api.get_channels("lv")
337
-    #prog = api.get_programs(channel=6400)
338
-    #prog = api.get_programs(category=55)
339
-    #seas = api.get_seasons(program=6453)
340
-    #str = api.get_streams(660243)
341
-    #res = api.get_videos(802)
342
-    #formats = api.getAllFormats()
343
-    #det = api.detailed("1516")
344
-    #vid = api.getVideos("13170")
345
-    pass
328
+    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
329
+    import run
330
+    source = Source()
331
+    data= sys.argv[1] if len(sys.argv)>1 else source.name+"::home"
332
+    run.run(source, data)
333
+    sys.exit()

+ 7
- 21
sources/ustvnow.py Datei anzeigen

@@ -80,7 +80,7 @@ class Source(SourceBase):
80 80
         lang = qs["lang"] if "lang" in qs else self.country
81 81
 
82 82
         content=[]
83
-        content.append(("..return", "back","","Return back"))
83
+        content.append(("..return", "back","back.png","Return back"))
84 84
 
85 85
         if clist=="home":
86 86
             content.extend([
@@ -171,23 +171,9 @@ Referer: http://watch.ustvnow.com/guide
171 171
 
172 172
 
173 173
 if __name__ == "__main__":
174
-    country= "lv"
175
-    c = Source(country)
176
-    if len(sys.argv)>1:
177
-        data= sys.argv[1]
178
-    else:
179
-        data = "home"
180
-    content = c.get_content(data)
181
-    for item in content:
182
-        print item
183
-    #cat = api.get_categories(country)
184
-    #chan = api.get_channels("lv")
185
-    #prog = api.get_programs(channel=6400)
186
-    #prog = api.get_programs(category=55)
187
-    #seas = api.get_seasons(program=6453)
188
-    #str = api.get_streams(660243)
189
-    #res = api.get_videos(802)
190
-    #formats = api.getAllFormats()
191
-    #det = api.detailed("1516")
192
-    #vid = api.getVideos("13170")
193
-    pass
174
+    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
175
+    import run
176
+    source = Source()
177
+    data= sys.argv[1] if len(sys.argv)>1 else source.name+"::home"
178
+    run.run(source, data)
179
+    sys.exit()

+ 6
- 18
sources/viaplay.py Datei anzeigen

@@ -187,7 +187,7 @@ Referer: https://viaplay.lv/
187 187
         print "[%s] get_content:"%self.name, data
188 188
         source,data,path,plist,clist,params,qs = self.parse_data(data)
189 189
         content=[]
190
-        content.append(("..return", "back","","Return back"))
190
+        content.append(("..return", "back","back.png","Return back"))
191 191
 
192 192
         if clist=="home":
193 193
             content.extend([
@@ -452,23 +452,11 @@ Referer: https://viaplay.lv/
452 452
         return content
453 453
 
454 454
 if __name__ == "__main__":
455
-    if len(sys.argv)>1:
456
-        data= sys.argv[1]
457
-    else:
458
-        data = "kids/child-and-karlson"
459
-    c = Source()
460
-    print "login: %s"%c.login()
461
-    if "/" in data:
462
-        streams = c.get_streams(data)
463
-        util.play_video(streams)
464
-    else:
465
-        vinfo = c.get_video_info(data)
466
-        if "HLS" in vinfo["tracks"] and vinfo["tracks"]["HLS"]:
467
-            url = vinfo["tracks"]["HLS"][0]["src"]
468
-            urlp = util.streamproxy_encode(url)
469
-            util.player(urlp)
470
-        else:
471
-            print "No HLS stream"
455
+    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
456
+    import run
457
+    source = Source()
458
+    data= sys.argv[1] if len(sys.argv)>1 else source.name+"::home"
459
+    run.run(source, data)
472 460
     sys.exit()
473 461
 
474 462
     r = requests.get("https://viaplay.lv/movies?sections[]=MOVIES")

+ 0
- 63
util.py Datei anzeigen

@@ -116,69 +116,6 @@ def nfo2title(nfo):
116 116
         title += " (%s)"%nfo["year"]
117 117
     return title.encode("utf8") if isinstance(title,unicode) else title
118 118
 
119
-def play_video(streams):
120
-    if len(streams)>1:
121
-        for i,s in enumerate(streams):
122
-
123
-            print "%s: [%s,%s,%s] %s"%(i,s["quality"],s["lang"],s["type"],s["name"])
124
-        a = raw_input("Select stram to play: ")
125
-        try:
126
-            n = int(a)
127
-        except:
128
-            n = 0
129
-        if n>=len(streams):
130
-            stream = streams[-1]
131
-        else:
132
-            stream = streams[n]
133
-    else:
134
-        stream = streams[0]
135
-
136
-    stream = stream_change(stream)
137
-    title = stream["name"] if not "nfo" in stream or not stream["nfo"] else nfo2title(stream["nfo"])
138
-    desc = stream["desc"] if not "nfo" in stream or not stream["nfo"] else nfo2desc(stream["nfo"])
139
-    img = stream["img"]
140
-    url = stream["url"]
141
-    suburl = ""
142
-    print url
143
-    if "subs" in stream and stream["subs"]:
144
-        suburl = stream["subs"][0]["url"]
145
-        print "\n**Download subtitles %s - %s"%(title,suburl)
146
-        subs = urllib2.urlopen(suburl).read()
147
-        if subs:
148
-            fname0 = re.sub("[/\n\r\t,:\?]","_",title)
149
-            subext = ".srt"
150
-            subfile = os.path.join("",fname0+subext)
151
-            if ".xml" in suburl:
152
-                subs = ttaf2srt(subs)
153
-            with open(subfile,"w") as f:
154
-                f.write(subs)
155
-        else:
156
-            print "\n Error downloading subtitle %s"%suburl
157
-    print "\n**Play stream %s\n%s" % (title, url.encode("utf8"))
158
-    return player(url,title,suburl,stream["headers"])
159
-
160
-def player(url, title = "", suburl= "",headers={}):
161
-    from subprocess import call
162
-    cmd1 = [r"c:\Program Files\VideoLAN\VLC\vlc.exe",url,
163
-           "--meta-title",title.decode("utf8").encode(sys.getfilesystemencoding()),
164
-           "--http-user-agent","Enigma2"
165
-    ]
166
-    # gst-launch-1.0 -v souphttpsrc ssl-strict=false proxy=127.0.0.1:8888 extra-headers="Origin:adadadasd"  location="http://bitdash-a.akamaihd.net/content/sintel/sintel.mpd" ! decodebin! autovideosink
167
-    cmd2 = [
168
-        r"C:\gstreamer\1.0\x86_64\bin\gst-launch-1.0","-v",
169
-        "playbin", 'uri="%s"'%url,
170
-        #"souphttpsrc", "ssl-strict=false",
171
-        #"proxy=127.0.0.1:8888",
172
-        #'location="%s"'%url,
173
-        #'!decodebin!autovideosink'
174
-    ]
175
-    cmd3 = ["ffplay.exe",url]
176
-    cmd = cmd3 if url.startswith("https") else cmd2
177
-    ret = call(cmd)
178
-    #if ret:
179
-        #a = raw_input("*** Error, continue")
180
-    return
181
-
182 119
 def stream_type(data):
183 120
     data = data.lower()
184 121
     m = re.search(r"^(\w+)://", data)