|
@@ -65,11 +65,13 @@ def make_service(stream):
|
65
|
65
|
url = url.encode("utf8")
|
66
|
66
|
if "|" in url:
|
67
|
67
|
url = url.replace("|","#")
|
68
|
|
- #url = url.replace(":","%3a")
|
|
68
|
+ service_type = 4097
|
69
|
69
|
if re.search("\.ts$",url.split("?")[0],re.IGNORECASE):
|
70
|
70
|
service_type = 1
|
71
|
|
- else:
|
72
|
|
- service_type = 4097
|
|
71
|
+ if "resolver" in stream and stream["resolver"] in ("hqq","viaplay"):
|
|
72
|
+ url = util.streamproxy_encode(stream["url"], stream["headers"])
|
|
73
|
+ if os.path.exists("/usr/bin/exteplayer3"): # problem playing hqq streams with gstreamer, use exteplayer3
|
|
74
|
+ service_type = 5002
|
73
|
75
|
print "service_type=",service_type
|
74
|
76
|
print "stream_url=",url
|
75
|
77
|
service = eServiceReference(service_type, 0, url)
|
|
@@ -91,8 +93,8 @@ class PSSubs(Screen):
|
91
|
93
|
</screen>""" % (offset, desktopHeight-offset-140, screenWidth, screenWidth)
|
92
|
94
|
self['subtitle'] = Label()
|
93
|
95
|
Screen.__init__(self, session)
|
94
|
|
-
|
95
|
|
-
|
|
96
|
+
|
|
97
|
+
|
96
|
98
|
#####################################################################################################################
|
97
|
99
|
class PSPlayer(MoviePlayer):
|
98
|
100
|
def __init__(self, session, streams):
|
|
@@ -103,24 +105,24 @@ class PSPlayer(MoviePlayer):
|
103
|
105
|
self.selected = 0
|
104
|
106
|
self.resume_pos = 0
|
105
|
107
|
service = make_service(self.cur_stream)
|
106
|
|
-
|
|
108
|
+
|
107
|
109
|
MoviePlayer.__init__(self, session, service)
|
108
|
|
- self.skinName = "MoviePlayer"
|
|
110
|
+ self.skinName = "MoviePlayer"
|
109
|
111
|
self["actions"] = ActionMap(["MediaPlayerActions","MediaPlayerSeekActions","MoviePlayerActions","InfobarSeekActions","MovieSelectionActions","ColorActions"], {
|
110
|
112
|
"stop":self.leavePlayer,
|
111
|
113
|
"leavePlayer":self.leavePlayer,
|
112
|
|
-
|
|
114
|
+
|
113
|
115
|
"audio":self.select_stream,
|
114
|
116
|
"AudioSelection":self.select_stream,
|
115
|
117
|
"green":self.select_stream,
|
116
|
|
-
|
|
118
|
+
|
117
|
119
|
"subtitles":self.select_captions,
|
118
|
120
|
"text":self.select_captions,
|
119
|
121
|
"yellow_key":self.select_captions,
|
120
|
122
|
"yellow":self.select_captions,
|
121
|
123
|
"pauseServiceYellow":self.select_captions,
|
122
|
124
|
"pause":self.select_captions,
|
123
|
|
-
|
|
125
|
+
|
124
|
126
|
"showEventInfo":self.service_info,
|
125
|
127
|
"info":self.service_info
|
126
|
128
|
})
|
|
@@ -141,16 +143,16 @@ class PSPlayer(MoviePlayer):
|
141
|
143
|
else:
|
142
|
144
|
self.subs = []
|
143
|
145
|
self.cur_subs = 0
|
144
|
|
- self.svisible = False
|
|
146
|
+ self.svisible = False
|
145
|
147
|
self.subtitle_window = self.session.instantiateDialog (PSSubs)
|
146
|
148
|
self.onLayoutFinish.append(self.start_subtitles_timer)
|
147
|
|
-
|
|
149
|
+
|
148
|
150
|
def start_subtitles_timer(self):
|
149
|
151
|
if self.stimer:
|
150
|
152
|
self.subtitle_window.show()
|
151
|
153
|
print "start_subtitles_timer"
|
152
|
154
|
self.stimer.start(self.stimer_step)
|
153
|
|
-
|
|
155
|
+
|
154
|
156
|
def get_sub_pts(self,pts):
|
155
|
157
|
sc = self.get_sub_ind(self.sind) # current subbtitle
|
156
|
158
|
while True:
|
|
@@ -166,14 +168,14 @@ class PSPlayer(MoviePlayer):
|
166
|
168
|
else:
|
167
|
169
|
txt = sc["text"] if sc["text"] else " "
|
168
|
170
|
return txt
|
169
|
|
-
|
|
171
|
+
|
170
|
172
|
def get_sub_ind(self,ind):
|
171
|
173
|
subs_object = self.get_subs_current() # current subs object
|
172
|
174
|
if subs_object:
|
173
|
175
|
return subs_object.subs[ind] if ind<len(subs_object.subs) else None
|
174
|
176
|
else:
|
175
|
177
|
return None
|
176
|
|
-
|
|
178
|
+
|
177
|
179
|
def get_subs_current(self):
|
178
|
180
|
"Return current sub_object"
|
179
|
181
|
if not "subs" in self.subs[self.cur_subs]:
|
|
@@ -187,7 +189,7 @@ class PSPlayer(MoviePlayer):
|
187
|
189
|
return subs_object
|
188
|
190
|
else:
|
189
|
191
|
return self.subs[self.cur_subs]["subs"]
|
190
|
|
-
|
|
192
|
+
|
191
|
193
|
def update_subtitles(self):
|
192
|
194
|
if not self.shown and self.svisible:
|
193
|
195
|
seek = self.getSeek()
|
|
@@ -209,8 +211,8 @@ class PSPlayer(MoviePlayer):
|
209
|
211
|
elif not self.svisible:
|
210
|
212
|
if self.subtitle_window.shown:
|
211
|
213
|
self.subtitle_window.hide()
|
212
|
|
-
|
213
|
|
-
|
|
214
|
+
|
|
215
|
+
|
214
|
216
|
# struct SubtitleTrack
|
215
|
217
|
# int type;
|
216
|
218
|
# int pid;
|
|
@@ -219,21 +221,21 @@ class PSPlayer(MoviePlayer):
|
219
|
221
|
# std::string language_code;
|
220
|
222
|
#selectedSubtitle = ???
|
221
|
223
|
#self.enableSubtitle(selectedSubtitle)
|
222
|
|
-
|
|
224
|
+
|
223
|
225
|
def start_subtitles_timer(self):
|
224
|
226
|
self.stimer.start(self.stimer_step)
|
225
|
|
-
|
|
227
|
+
|
226
|
228
|
def play_service(self,service):
|
227
|
229
|
self.movieSelected(service)
|
228
|
|
-
|
|
230
|
+
|
229
|
231
|
#def doShow(self):
|
230
|
232
|
#self.svisible = False
|
231
|
233
|
#InfoBarShowHide.doShow(self)
|
232
|
|
-
|
|
234
|
+
|
233
|
235
|
#def doHide(self):
|
234
|
236
|
#self.svisible = True
|
235
|
237
|
#InfoBarShowHide.doHide(self)
|
236
|
|
-
|
|
238
|
+
|
237
|
239
|
def service_info(self):
|
238
|
240
|
print "########[MoviePlayer] service_info"
|
239
|
241
|
text = "%s\n%s %s\n%s"%(self.cur_stream["name"],self.cur_stream["lang"],self.cur_stream["quality"],self.cur_stream["desc"])
|
|
@@ -241,19 +243,19 @@ class PSPlayer(MoviePlayer):
|
241
|
243
|
#print text
|
242
|
244
|
mtype = MessageBox.TYPE_INFO
|
243
|
245
|
Notifications.AddPopup(text = text, type=mtype, timeout = 10)
|
244
|
|
- #Notifications.MessageBox(self.session, text=text, type=MessageBox.TYPE_INFO, timeout=10,
|
245
|
|
- #close_on_any_key=True,
|
246
|
|
- #default=True,
|
247
|
|
- #enable_input=True,
|
248
|
|
- #msgBoxID=None,
|
249
|
|
- #picon=False,
|
250
|
|
- #simple=False,
|
251
|
|
- #wizard=False,
|
252
|
|
- #list=None,
|
253
|
|
- #skin_name=None,
|
|
246
|
+ #Notifications.MessageBox(self.session, text=text, type=MessageBox.TYPE_INFO, timeout=10,
|
|
247
|
+ #close_on_any_key=True,
|
|
248
|
+ #default=True,
|
|
249
|
+ #enable_input=True,
|
|
250
|
+ #msgBoxID=None,
|
|
251
|
+ #picon=False,
|
|
252
|
+ #simple=False,
|
|
253
|
+ #wizard=False,
|
|
254
|
+ #list=None,
|
|
255
|
+ #skin_name=None,
|
254
|
256
|
#timeout_default=None)
|
255
|
257
|
#return True
|
256
|
|
-
|
|
258
|
+
|
257
|
259
|
def select_stream(self):
|
258
|
260
|
print "########[MoviePlayer] select_stream"
|
259
|
261
|
lst = []
|
|
@@ -268,7 +270,7 @@ class PSPlayer(MoviePlayer):
|
268
|
270
|
return
|
269
|
271
|
self.selected = answer[1]
|
270
|
272
|
service = make_service(self.streams[self.selected])
|
271
|
|
- self.resume_pos = self.getSeek().getPlayPosition()[1]
|
|
273
|
+ self.resume_pos = self.getSeek().getPlayPosition()[1]
|
272
|
274
|
self.play_service(service)
|
273
|
275
|
|
274
|
276
|
def serviceStarted(self):
|
|
@@ -277,8 +279,8 @@ class PSPlayer(MoviePlayer):
|
277
|
279
|
self.resume_pos = 0
|
278
|
280
|
print "doSeek",self.resume_pos
|
279
|
281
|
#self.doSeek(self.resume_pos)
|
280
|
|
-
|
281
|
|
-
|
|
282
|
+
|
|
283
|
+
|
282
|
284
|
def select_captions(self):
|
283
|
285
|
print "########[MoviePlayer] select_caption"
|
284
|
286
|
lst = []
|
|
@@ -325,7 +327,7 @@ class PSPlayer(MoviePlayer):
|
325
|
327
|
#def showMovies(self):
|
326
|
328
|
#pass
|
327
|
329
|
|
328
|
|
-
|
|
330
|
+
|
329
|
331
|
#####################################################################################################################
|
330
|
332
|
class MainScreen(Screen):
|
331
|
333
|
skin = """
|
|
@@ -356,7 +358,7 @@ class MainScreen(Screen):
|
356
|
358
|
<widget name="key_yellow" position="430,535" size="140,40" valign="center" halign="center" zPosition="4" foregroundColor="white" font="Regular;20" transparent="1" shadowColor="background" shadowOffset="-2,-2" />
|
357
|
359
|
<ePixmap name="menu" position="610,540" zPosition="2" size="140,40" pixmap="skin_default/buttons/key_menu.png" transparent="1" alphatest="on" />
|
358
|
360
|
<widget name="key_menu" position="610,535" size="140,40" valign="center" halign="center" zPosition="4" backgroundColor="blue" foregroundColor="white" font="Regular;20" transparent="1" shadowColor="background" shadowOffset="-2,-2" />
|
359
|
|
-
|
|
361
|
+
|
360
|
362
|
</screen>"""
|
361
|
363
|
|
362
|
364
|
def __init__(self, session):
|
|
@@ -369,7 +371,7 @@ class MainScreen(Screen):
|
369
|
371
|
self["key_yellow"] = Button(_("Options"))
|
370
|
372
|
self["key_menu"] = Button("Menu")
|
371
|
373
|
self["key_exit"] = Button("Back")
|
372
|
|
-
|
|
374
|
+
|
373
|
375
|
self["actions"] = ActionMap(["OkCancelActions", "ColorActions","MenuActions", "NumberActions"],
|
374
|
376
|
{
|
375
|
377
|
#"cancel": self.Cancel,
|
|
@@ -401,13 +403,13 @@ class MainScreen(Screen):
|
401
|
403
|
#self.defimage0.PictureData.get().append(boundFunction(self.FinishDecodeDef, os.path.join(self.cur_directory,"PlayStream.png")))
|
402
|
404
|
#self.defimage0.setPara((self["pic"].instance.size().width(),self["pic"].instance.size().height(),sc[0], sc[1], False, 0, "#00000000"))
|
403
|
405
|
#self.defimage0.startDecode("default")
|
404
|
|
-
|
|
406
|
+
|
405
|
407
|
self.activeDownloads = 0
|
406
|
408
|
self.images = {}
|
407
|
409
|
self.images_url = {}
|
408
|
410
|
self.picloads = {}
|
409
|
411
|
self.history = []
|
410
|
|
-
|
|
412
|
+
|
411
|
413
|
reload(ContentSources)
|
412
|
414
|
self.sources = ContentSources.ContentSources(os.path.join(self.cur_directory,"sources"))
|
413
|
415
|
self.config = self.sources.plugins["config"]
|
|
@@ -433,7 +435,7 @@ class MainScreen(Screen):
|
433
|
435
|
def setTitle2(self,title):
|
434
|
436
|
#print self.keys()
|
435
|
437
|
self["title"].setText(title)
|
436
|
|
-
|
|
438
|
+
|
437
|
439
|
def ShowDefPic(self):
|
438
|
440
|
if self.defimage:
|
439
|
441
|
self["pic"].instance.setPixmap(self.defimage)
|
|
@@ -458,7 +460,7 @@ class MainScreen(Screen):
|
458
|
460
|
else: # local file
|
459
|
461
|
image_path = os.path.join(self.cur_directory,image_url)
|
460
|
462
|
self.start_decode(image_path,image_url)
|
461
|
|
-
|
|
463
|
+
|
462
|
464
|
def start_decode(self,image_path,image_url):
|
463
|
465
|
self.images[image_url] = -2
|
464
|
466
|
self.images_url[image_path] = image_url
|
|
@@ -481,12 +483,12 @@ class MainScreen(Screen):
|
481
|
483
|
if len(self.images)>30:
|
482
|
484
|
del self.images[self.images.keys()[0]]
|
483
|
485
|
# self.images.pop()
|
484
|
|
-
|
|
486
|
+
|
485
|
487
|
#def FinishDecodeDef(self, image_path,picInfo = None):
|
486
|
488
|
# self.defimage = self.defimage0.getData()
|
487
|
489
|
# del self.defimage0
|
488
|
490
|
# self["pic"].instance.setPixmap(self.defimage)
|
489
|
|
-
|
|
491
|
+
|
490
|
492
|
def download_image(self,image_path,image_url):
|
491
|
493
|
#print "Image download started",self.downloading,image_path,image_url
|
492
|
494
|
self.downloading += 1
|
|
@@ -496,7 +498,7 @@ class MainScreen(Screen):
|
496
|
498
|
def downloadFinished(self, image_path, image_url, result):
|
497
|
499
|
self.downloading -= 1
|
498
|
500
|
#print "[ Play] Image downloaded finished ",self.downloading,image_path, image_url,result
|
499
|
|
- self.start_decode(image_path,image_url)
|
|
501
|
+ self.start_decode(image_path,image_url)
|
500
|
502
|
|
501
|
503
|
def downloadFailed(self, image_path, image_url,result):
|
502
|
504
|
self.downloading -= 1
|
|
@@ -513,7 +515,7 @@ class MainScreen(Screen):
|
513
|
515
|
data = current[1].split("::")[1] if "::" in current[1] else current[1]
|
514
|
516
|
if not data:
|
515
|
517
|
return
|
516
|
|
-
|
|
518
|
+
|
517
|
519
|
elif self.sources.is_video(current[1]):
|
518
|
520
|
if self.sources.stream_type(current[1]):
|
519
|
521
|
stream = stream0.copy()
|
|
@@ -521,7 +523,7 @@ class MainScreen(Screen):
|
521
|
523
|
stream["name"] = current[0]
|
522
|
524
|
streams = [stream]
|
523
|
525
|
else:
|
524
|
|
- try:
|
|
526
|
+ try:
|
525
|
527
|
streams = self.sources.get_streams(current[1])
|
526
|
528
|
except Exception,e:
|
527
|
529
|
print str(e)
|
|
@@ -541,7 +543,7 @@ class MainScreen(Screen):
|
541
|
543
|
else:
|
542
|
544
|
self.msg("No stream found - %s"%(self.current[1]))
|
543
|
545
|
return
|
544
|
|
-
|
|
546
|
+
|
545
|
547
|
elif current[1] == "back":
|
546
|
548
|
cur_menu_old = self.cur_menu
|
547
|
549
|
self.cur_menu = self.history.pop()
|
|
@@ -552,38 +554,38 @@ class MainScreen(Screen):
|
552
|
554
|
index = 0
|
553
|
555
|
self.setTitle2(self.cur_menu[0])
|
554
|
556
|
self.show_content(new_content,index)
|
555
|
|
-
|
|
557
|
+
|
556
|
558
|
else:
|
557
|
559
|
print "selected=",current
|
558
|
560
|
if "{0}" in current[1]:
|
559
|
|
- self.session.openWithCallback(self.cb_input,VirtualKeyBoard, title="Enter value", text="")
|
|
561
|
+ self.session.openWithCallback(self.cb_input,VirtualKeyBoard, title="Enter value", text="")
|
560
|
562
|
#a = raw_input("Enter value:")
|
561
|
563
|
#a = "big bang"
|
562
|
564
|
#current = (current[0],current[1].format(a),current[2],current[3])
|
563
|
565
|
#self.get_content(current)
|
564
|
566
|
else:
|
565
|
567
|
self.get_content(current)
|
566
|
|
-
|
567
|
|
-
|
|
568
|
+
|
|
569
|
+
|
568
|
570
|
def cb_input(self,value):
|
569
|
571
|
if not value:
|
570
|
572
|
return
|
571
|
573
|
current = self.current
|
572
|
574
|
current = (current[0],current[1].format(value),current[2],current[3])
|
573
|
575
|
self.get_content(current)
|
574
|
|
-
|
575
|
|
- def get_content(self,current):
|
|
576
|
+
|
|
577
|
+ def get_content(self,current):
|
576
|
578
|
self.history.append(self.cur_menu)
|
577
|
579
|
self.cur_menu = current
|
578
|
580
|
try:
|
579
|
581
|
new_content = self.sources.get_content(self.cur_menu[1])
|
580
|
582
|
except Exception,e:
|
581
|
|
- self.cur_menu = self.history.pop()
|
|
583
|
+ self.cur_menu = self.history.pop()
|
582
|
584
|
self.session. open(MessageBox, "Error - %s"%str(e) , MessageBox.TYPE_INFO)
|
583
|
585
|
return
|
584
|
586
|
self.setTitle2(self.cur_menu[0])
|
585
|
587
|
self.show_content(new_content)
|
586
|
|
-
|
|
588
|
+
|
587
|
589
|
def Back(self):
|
588
|
590
|
self["list"].setIndex(0)
|
589
|
591
|
self.Ok()
|
|
@@ -599,12 +601,12 @@ class MainScreen(Screen):
|
599
|
601
|
#os.remove(os.path.join(TMPDIR, name))
|
600
|
602
|
#os.rmdir(TMPDIR)
|
601
|
603
|
self.close()
|
602
|
|
-
|
603
|
|
-
|
|
604
|
+
|
|
605
|
+
|
604
|
606
|
def item_menu(self):
|
605
|
607
|
print "\n[PlayStream] options\n"
|
606
|
608
|
self.current = self["list"].getCurrent()
|
607
|
|
- self.index = self["list"].getIndex()
|
|
609
|
+ self.index = self["list"].getIndex()
|
608
|
610
|
#self.session. open(MessageBox, "Item options - %s"%current[0] , MessageBox.TYPE_INFO)
|
609
|
611
|
#args=[current,self.cur_menu]
|
610
|
612
|
#self.session.open(ItemMenuScreen,current,index,self)
|
|
@@ -622,13 +624,13 @@ class MainScreen(Screen):
|
622
|
624
|
else:
|
623
|
625
|
lst.extend([
|
624
|
626
|
("Download videos in folder","download","Download videos in folder (if any)"),
|
625
|
|
- ])
|
|
627
|
+ ])
|
626
|
628
|
if "config::" in self.cur_menu[1]:
|
627
|
629
|
lst.extend([
|
628
|
630
|
("Rename item","rename","Rename list item"),
|
629
|
631
|
("Move item","move","Move list item"),
|
630
|
632
|
("Delete item","delete","Delete list item"),
|
631
|
|
- ("Add submenu","add_list","Add submenu before selected item"),
|
|
633
|
+ ("Add submenu","add_list","Add submenu before selected item"),
|
632
|
634
|
])
|
633
|
635
|
title = self.current[0]
|
634
|
636
|
self.session.openWithCallback(self.cb_item_menu, ChoiceBox, title = title, list = lst) #TODO
|
|
@@ -641,18 +643,18 @@ class MainScreen(Screen):
|
641
|
643
|
if answer[1] == "info":
|
642
|
644
|
self.session.open(MessageBox, "Not yet implemented!", MessageBox.TYPE_INFO)
|
643
|
645
|
pass # TODO parada papildus info
|
644
|
|
-
|
|
646
|
+
|
645
|
647
|
elif answer[1] == "bouquet":
|
646
|
648
|
#if not e2:
|
647
|
649
|
#e2 = enigma2_api.DBServices()
|
648
|
650
|
#print "load_buuquets - ",e2._load_bouquets()
|
649
|
|
- self.session.open(MessageBox, "Not yet implemented!", MessageBox.TYPE_INFO)
|
650
|
|
-
|
|
651
|
+ self.session.open(MessageBox, "Not yet implemented!", MessageBox.TYPE_INFO)
|
|
652
|
+
|
651
|
653
|
elif answer[1] == "favorites":
|
652
|
654
|
lists = self.config.get_lists()
|
653
|
|
- lists2 = [(l,l) for l in lists]
|
654
|
|
- self.session.openWithCallback(self.cb_favorites, ChoiceBox, title="Selected menu item will be added",list = lists2)
|
655
|
|
-
|
|
655
|
+ lists2 = [(l,l) for l in lists]
|
|
656
|
+ self.session.openWithCallback(self.cb_favorites, ChoiceBox, title="Selected menu item will be added",list = lists2)
|
|
657
|
+
|
656
|
658
|
elif answer[1] == 'download':
|
657
|
659
|
current = self.current
|
658
|
660
|
if not self.sources.is_video(current[1]):
|
|
@@ -665,36 +667,36 @@ class MainScreen(Screen):
|
665
|
667
|
if n>0:
|
666
|
668
|
self.msg("%s videos download started"%n)
|
667
|
669
|
else:
|
668
|
|
- self.msg("No videos to download")
|
|
670
|
+ self.msg("No videos to download")
|
669
|
671
|
else:
|
670
|
672
|
if self.download_video(current):
|
671
|
673
|
self.msg("Video download started")
|
672
|
|
-
|
673
|
|
-
|
|
674
|
+
|
|
675
|
+
|
674
|
676
|
elif answer[1] == 'download_list':
|
675
|
677
|
self.download_list()
|
676
|
|
-
|
|
678
|
+
|
677
|
679
|
elif answer[1] == 'download_folder':
|
678
|
680
|
#downloadDir = "/media/hdd/movie" #config.plugins.playstream.downloadDir.value TODO
|
679
|
681
|
self.session.openWithCallback(self.select_download_dir, LocationBox,"Select download folder","",config.playstream.download_dir.value,config.playstream.locations,False,"Select folder",None,True,True)
|
680
|
|
-
|
|
682
|
+
|
681
|
683
|
elif answer[1] == "delete":
|
682
|
684
|
lst = self.cur_menu[1].replace("config::","")
|
683
|
685
|
#print lst
|
684
|
686
|
self.config.del_item(lst,self.index)
|
685
|
687
|
self.config.write_streams()
|
686
|
688
|
txt = "'%s' deleted from favourite stream list '%s'"%(self.current[0],lst)
|
687
|
|
- self.session.open(MessageBox, txt, MessageBox.TYPE_INFO,timeout=5)
|
688
|
|
-
|
|
689
|
+ self.session.open(MessageBox, txt, MessageBox.TYPE_INFO,timeout=5)
|
|
690
|
+
|
689
|
691
|
elif answer[1] == "rename":
|
690
|
692
|
#name2 = "Renamed"
|
691
|
|
- self.session.openWithCallback(self.cb_rename,VirtualKeyBoard, title="Enter new item name", text=self.current[0])
|
692
|
|
-
|
|
693
|
+ self.session.openWithCallback(self.cb_rename,VirtualKeyBoard, title="Enter new item name", text=self.current[0])
|
|
694
|
+
|
693
|
695
|
elif answer[1] == "add_list":
|
694
|
|
- self.session.open(MessageBox, "Not yet implemented!", MessageBox.TYPE_INFO,timeout=5)
|
695
|
|
- pass #TODO
|
|
696
|
+ self.session.open(MessageBox, "Not yet implemented!", MessageBox.TYPE_INFO,timeout=5)
|
|
697
|
+ pass #TODO
|
696
|
698
|
return
|
697
|
|
-
|
|
699
|
+
|
698
|
700
|
def select_download_dir(self, downloadDir, select=None):
|
699
|
701
|
if not downloadDir:
|
700
|
702
|
return
|
|
@@ -702,11 +704,11 @@ class MainScreen(Screen):
|
702
|
704
|
config.playstream.download_dir.setValue(downloadDir)
|
703
|
705
|
config.playstream.download_dir.save()
|
704
|
706
|
config.playstream.locations.save()
|
705
|
|
- config.save()
|
|
707
|
+ config.save()
|
706
|
708
|
|
707
|
709
|
def download_list(self):
|
708
|
710
|
self.session.open(VideoDownloadList)
|
709
|
|
-
|
|
711
|
+
|
710
|
712
|
def download_video(self,current):
|
711
|
713
|
if self.sources.stream_type(current[1]):
|
712
|
714
|
stream = stream0.copy()
|
|
@@ -714,7 +716,7 @@ class MainScreen(Screen):
|
714
|
716
|
stream["name"] = current[0]
|
715
|
717
|
streams = [stream]
|
716
|
718
|
else:
|
717
|
|
- try:
|
|
719
|
+ try:
|
718
|
720
|
streams = self.sources.get_streams(current[1])
|
719
|
721
|
except Exception,e:
|
720
|
722
|
print "Error - %s"%str(e)
|
|
@@ -727,11 +729,12 @@ class MainScreen(Screen):
|
727
|
729
|
if not s["name"]: s["name"] = current[0]
|
728
|
730
|
if not s["img"]: s["img"] = current[2]
|
729
|
731
|
if not s["desc"]: s["desc"] = current[3]
|
730
|
|
-
|
|
732
|
+
|
731
|
733
|
if len(streams)>1:
|
732
|
734
|
stream = streams[0] # TODO iespeja izvelēties strīmu, ja to ir vairāki
|
733
|
735
|
else:
|
734
|
736
|
stream = streams[0]
|
|
737
|
+ stream = util.stream_change(stream)
|
735
|
738
|
return self.download_stream(stream)
|
736
|
739
|
|
737
|
740
|
def download_stream(self,stream):
|
|
@@ -739,11 +742,11 @@ class MainScreen(Screen):
|
739
|
742
|
#self.msg("Start downloading..")
|
740
|
743
|
self.stream = stream
|
741
|
744
|
stream_type = self.stream["type"] #self.sources.stream_type(stream["url"])
|
742
|
|
- if not stream_type: #
|
|
745
|
+ if not stream_type: #
|
743
|
746
|
print "Not supported stream type found to download - %s"%(self.current[1])
|
744
|
747
|
self.msg("Not supported stream type found to download - %s"%(self.current[1]))
|
745
|
748
|
return
|
746
|
|
-
|
|
749
|
+
|
747
|
750
|
title = self.stream["name"].strip()
|
748
|
751
|
url = self.stream["url"]
|
749
|
752
|
stream_type = self.stream["type"] #self.sources.stream_type(stream["url"])
|
|
@@ -759,55 +762,55 @@ class MainScreen(Screen):
|
759
|
762
|
#print "Trying to download - ", current
|
760
|
763
|
if self.stream["subs"]:
|
761
|
764
|
suburl = self.stream["subs"][0]["url"]
|
762
|
|
- print "\n**Download subtitles %s - %s"%(title,suburl)
|
|
765
|
+ print "\n**Download subtitles %s - %s"%(title,suburl)
|
763
|
766
|
subs = urllib2.urlopen(suburl).read()
|
764
|
767
|
if subs:
|
765
|
|
- #fname0 = re.sub("[/\n\r\t,:]"," ",title)
|
|
768
|
+ #fname0 = re.sub("[/\n\r\t,:]"," ",title)
|
766
|
769
|
subext = ".srt"
|
767
|
770
|
subfile = os.path.join(downloadDir,fname0+subext)
|
768
|
771
|
if ".xml" in suburl:
|
769
|
|
- subs = util.ttaf2srt(subs)
|
|
772
|
+ subs = util.ttaf2srt(subs)
|
770
|
773
|
with open(subfile,"w") as f:
|
771
|
774
|
f.write(subs)
|
772
|
775
|
else:
|
773
|
776
|
print "\n Error downloading subtitle %s"%suburl
|
774
|
|
-
|
|
777
|
+
|
775
|
778
|
if os.path.exists(outputfile):
|
776
|
779
|
self.msg( _('Sorry, this file already exists:\n%s') % outputfile)
|
777
|
780
|
return False
|
778
|
781
|
#os.remove(outputfile)
|
779
|
|
-
|
780
|
|
- if stream_type in ("http","https"):
|
781
|
|
- print "\n**Download %s - %s"%(title,url)
|
|
782
|
+
|
|
783
|
+ if stream_type in ("http","https"):
|
|
784
|
+ print "\n**Download %s - %s"%(title,url)
|
782
|
785
|
#reload(downloadJob)
|
783
|
786
|
job_manager.AddJob(downloadJob(url, outputfile, title[:20], self.video_download_stop))
|
784
|
787
|
self.activeDownloads += 1
|
785
|
788
|
#self.msg(_('Video download started!'))
|
786
|
789
|
return True
|
787
|
|
-
|
|
790
|
+
|
788
|
791
|
elif stream_type == "hls":
|
789
|
792
|
#self.msg("HLS stream download not yet implemented!")
|
790
|
|
- print "\n**Download %s - %s"%(title,url)
|
|
793
|
+ print "\n**Download %s - %s"%(title,url)
|
791
|
794
|
#reload(HLSDownloadJob)
|
792
|
795
|
print "HLSDownload", url,outputfile
|
793
|
796
|
job_manager.AddJob(HLSDownloadJob(url, outputfile, title[:20], self.video_download_stop))
|
794
|
797
|
self.activeDownloads += 1
|
795
|
798
|
#self.msg(_('Video download started!'))
|
796
|
799
|
return True
|
797
|
|
-
|
|
800
|
+
|
798
|
801
|
elif stream_type == "rstp":
|
799
|
802
|
self.msg("RSTP stream download not yet implemented!")
|
800
|
803
|
return False
|
801
|
804
|
else:
|
802
|
805
|
self.msg("Unkown stream type!")
|
803
|
806
|
return False
|
804
|
|
-
|
805
|
|
-
|
|
807
|
+
|
|
808
|
+
|
806
|
809
|
def cb_rename(self,value):
|
807
|
810
|
if not value:
|
808
|
811
|
return
|
809
|
812
|
lst = self.cur_menu[1].replace("config::","")
|
810
|
|
- pos = self.index
|
|
813
|
+ pos = self.index
|
811
|
814
|
print value
|
812
|
815
|
item2 = list(self.current)
|
813
|
816
|
item2[0]=value
|
|
@@ -815,19 +818,19 @@ class MainScreen(Screen):
|
815
|
818
|
self.config.replace_item(lst,item2,pos)
|
816
|
819
|
self.config.write_streams()
|
817
|
820
|
txt = "'%s' renamed to '%s'"%(self.current[0],value)
|
818
|
|
- self.session.open(MessageBox, txt, MessageBox.TYPE_INFO,timeout=5)
|
819
|
|
-
|
|
821
|
+ self.session.open(MessageBox, txt, MessageBox.TYPE_INFO,timeout=5)
|
|
822
|
+
|
820
|
823
|
def cb_favorites(self,answer):
|
821
|
824
|
print "cb_favorites",answer,self.current
|
822
|
825
|
if not answer:
|
823
|
|
- return
|
|
826
|
+ return
|
824
|
827
|
value = answer[1]
|
825
|
828
|
self.config.add_item(value,self.current)
|
826
|
829
|
self.config.write_streams()
|
827
|
830
|
txt = "'%s' added to favourite stream list '%s'"%(self.current[0],value)
|
828
|
831
|
self.session.open(MessageBox, txt, MessageBox.TYPE_INFO,timeout=3)
|
829
|
832
|
#self.session.openWithCallback(self.callMyMsg, MessageBox, _("Do you want to exit the plugin?"), MessageBox.TYPE_INFO)
|
830
|
|
-
|
|
833
|
+
|
831
|
834
|
def options_screen(self):
|
832
|
835
|
source = self.cur_menu[1].split("::")[0]
|
833
|
836
|
options = self.sources.options_read(source)
|
|
@@ -835,17 +838,17 @@ class MainScreen(Screen):
|
835
|
838
|
if not options:
|
836
|
839
|
self.session. open(MessageBox, "No options available for source %s (%s)"%(self.cur_menu[0],source) , MessageBox.TYPE_INFO)
|
837
|
840
|
else:
|
838
|
|
- self.session.open(OptionsScreen,self)
|
839
|
|
-
|
|
841
|
+ self.session.open(OptionsScreen,self)
|
|
842
|
+
|
840
|
843
|
def video_download_stop(self,title):
|
841
|
844
|
#self.activeDownloads -= 1
|
842
|
845
|
#self.msg("Download '%s'finished!"%title)
|
843
|
846
|
print "video_download_stop ", title
|
844
|
|
-
|
|
847
|
+
|
845
|
848
|
def msg2(self,msg,timeout=10,mtype = None):
|
846
|
|
- mtype=mtype if mtype else MessageBox.TYPE_INFO
|
|
849
|
+ mtype=mtype if mtype else MessageBox.TYPE_INFO
|
847
|
850
|
Notifications.AddPopup(text = msg, type=mtype, timeout=timeout)
|
848
|
|
-
|
|
851
|
+
|
849
|
852
|
def msg(self,msg,timeout=10):
|
850
|
853
|
self.session.open(MessageBox, msg, MessageBox.TYPE_INFO, timeout)
|
851
|
854
|
##########################################################################
|
|
@@ -878,7 +881,7 @@ class OptionsScreen(ConfigListScreen,Screen):
|
878
|
881
|
self.setTitle(self.main.cur_menu[0]+" options")
|
879
|
882
|
self.source = self.main.cur_menu[1].split("::")[0]
|
880
|
883
|
self.cfg = config.plugins.playstream
|
881
|
|
- self.list = []
|
|
884
|
+ self.list = []
|
882
|
885
|
self.options = self.main.sources.options_read(self.source)
|
883
|
886
|
if not self.options:
|
884
|
887
|
#self.session. open(MessageBox, "No options available for source %s (%s)"%(self.main.cur_menu[0],self.source) , MessageBox.TYPE_INFO)
|
|
@@ -887,7 +890,7 @@ class OptionsScreen(ConfigListScreen,Screen):
|
887
|
890
|
self.cfg[k]=ConfigText(default=self.options[k],fixed_size=False)
|
888
|
891
|
self.list.append(getConfigListEntry(k, self.cfg[k]))
|
889
|
892
|
ConfigListScreen.__init__(self, self.list, session = self.session)
|
890
|
|
-
|
|
893
|
+
|
891
|
894
|
self["key_red"] = Button(_("Cancel"))
|
892
|
895
|
self["key_green"] = Button("Save")
|
893
|
896
|
self["key_yellow"] = Button("")
|
|
@@ -913,7 +916,7 @@ class OptionsScreen(ConfigListScreen,Screen):
|
913
|
916
|
#folder = config.plugins.getpicons.folder.value
|
914
|
917
|
#self.session.openWithCallback(self.change_dir, LocationBox,"Select Folder")
|
915
|
918
|
#else:
|
916
|
|
-
|
|
919
|
+
|
917
|
920
|
|
918
|
921
|
#def change_dir(self, folder, select=None):
|
919
|
922
|
#if folder:
|