|
@@ -1,12 +1,12 @@
|
1
|
1
|
#!/usr/bin/env python
|
2
|
2
|
# coding=utf8
|
3
|
|
-# This file is part of PlayStream - enigma2 plugin to play video streams from various sources
|
|
3
|
+# This file is part of PlayStream - enigma2 plughhhhin to play video streams from various sources
|
4
|
4
|
# Copyright (c) 2016 ivars777 (ivars777@gmail.com)
|
5
|
5
|
# Distributed under the GNU GPL v3. For full terms see http://www.gnu.org/licenses/gpl-3.0.en.html
|
6
|
6
|
# Used fragments of code from enigma2-plugin-tv3play by Taapat (https://github.com/Taapat/enigma2-plugin-tv3play)
|
7
|
7
|
#
|
8
|
8
|
|
9
|
|
-__version__ = "0.7e"
|
|
9
|
+__version__ = "0.7o"
|
10
|
10
|
__id__ = "playstream"
|
11
|
11
|
__title__ = "PlayStream"
|
12
|
12
|
__author__ = "ivars777@gmail.com"
|
|
@@ -49,12 +49,18 @@ from Tools.Directories import resolveFilename, SCOPE_PLUGINS
|
49
|
49
|
from Tools.LoadPixmap import LoadPixmap
|
50
|
50
|
from skin import loadSkin
|
51
|
51
|
from twisted.web.client import downloadPage,defer,reactor
|
|
52
|
+try:
|
|
53
|
+ # available since twisted 14.0
|
|
54
|
+ from twisted.internet._sslverify import ClientTLSOptions
|
|
55
|
+except ImportError:
|
|
56
|
+ ClientTLSOptions = None
|
|
57
|
+from twisted.internet.ssl import ClientContextFactory
|
52
|
58
|
|
53
|
59
|
from plugin_locale import _
|
54
|
|
-import ContentSources
|
55
|
|
-import util
|
|
60
|
+from content import ContentSources
|
|
61
|
+from content import util
|
56
|
62
|
from VideoDownload import DownloadJob, HLSDownloadJob,VideoDownloadList
|
57
|
|
-from Downloader import get_header, get_ext
|
|
63
|
+from content.Downloader import get_header, get_ext
|
58
|
64
|
#import enigma2_api
|
59
|
65
|
|
60
|
66
|
e2 = None
|
|
@@ -72,6 +78,16 @@ config.plugins.playstream.overwrite_download = ConfigYesNo(default = False)
|
72
|
78
|
config.plugins.playstream.clear_tmp = ConfigYesNo(default = True)
|
73
|
79
|
config.plugins.playstream.check_update = ConfigYesNo(default = True)
|
74
|
80
|
|
|
81
|
+
|
|
82
|
+class CustomContextFactory(ClientContextFactory):
|
|
83
|
+ def __init__(self, hostname = None):
|
|
84
|
+ self.hostname = hostname
|
|
85
|
+ def getContext(self):
|
|
86
|
+ ctx = self._contextFactory(self.method)
|
|
87
|
+ if self.hostname and ClientTLSOptions:
|
|
88
|
+ ClientTLSOptions(self.hostname, ctx)
|
|
89
|
+ return ctx
|
|
90
|
+
|
75
|
91
|
#####################################################################################################################
|
76
|
92
|
class MainScreen(Screen):
|
77
|
93
|
def __init__(self, session):
|
|
@@ -129,7 +145,7 @@ class MainScreen(Screen):
|
129
|
145
|
self.history = []
|
130
|
146
|
|
131
|
147
|
reload(ContentSources)
|
132
|
|
- self.sources = ContentSources.ContentSources(os.path.join(cur_directory,"sources"))
|
|
148
|
+ self.sources = ContentSources.ContentSources(os.path.join(cur_directory, "content", "sources"))
|
133
|
149
|
self.config = self.sources.plugins["config"]
|
134
|
150
|
self.cur_menu = ("Home","config::home","","Sākums") #
|
135
|
151
|
self.content = self.sources.get_content(self.cur_menu[1])
|
|
@@ -195,7 +211,7 @@ class MainScreen(Screen):
|
195
|
211
|
image_path = os.path.join(config.plugins.playstream.tmp_dir.value, fname)
|
196
|
212
|
self.download_image(image_path, image_url)
|
197
|
213
|
else: # local file
|
198
|
|
- image_path = os.path.join(cur_directory,image_url)
|
|
214
|
+ image_path = os.path.join(cur_directory, "picons", image_url)
|
199
|
215
|
self.start_decode(image_path,image_url)
|
200
|
216
|
|
201
|
217
|
def start_decode(self,image_path,image_url):
|
|
@@ -204,11 +220,14 @@ class MainScreen(Screen):
|
204
|
220
|
sc = AVSwitch().getFramebufferScale()
|
205
|
221
|
if not self.picloads.has_key(image_path):
|
206
|
222
|
self.picloads[image_path] = ePicLoad()
|
207
|
|
- self.picloads[image_path].PictureData.get().append(boundFunction(self.decode_finished, image_path))
|
|
223
|
+ try:
|
|
224
|
+ self.picloads[image_path].PictureData.get().append(boundFunction(self.decode_finished, image_path))
|
|
225
|
+ except:
|
|
226
|
+ self.picloads[image_path].PictureData.connect(boundFunction(self.decode_finished, image_path))
|
208
|
227
|
self.picloads[image_path].setPara((self["pic"].instance.size().width(),
|
209
|
228
|
self["pic"].instance.size().height(),
|
210
|
229
|
sc[0], sc[1], True, 0, "#00000000"))
|
211
|
|
- #print image_path,image_url
|
|
230
|
+ print image_path,image_url
|
212
|
231
|
self.picloads[image_path].startDecode(image_path)
|
213
|
232
|
|
214
|
233
|
def decode_finished(self, image_path, picInfo = None):
|
|
@@ -230,7 +249,7 @@ class MainScreen(Screen):
|
230
|
249
|
#print "Image download started",self.downloading,image_path,image_url
|
231
|
250
|
self.downloading += 1
|
232
|
251
|
self.images[image_url] = -1
|
233
|
|
- downloadPage(image_url, image_path).addCallback(boundFunction(self.download_image_finished, image_path, image_url)).addErrback(boundFunction(self.download_image_failed, image_path, image_url))
|
|
252
|
+ downloadPage(image_url, image_path, CustomContextFactory(image_url.split("/")[2])).addCallback(boundFunction(self.download_image_finished, image_path, image_url)).addErrback(boundFunction(self.download_image_failed, image_path, image_url))
|
234
|
253
|
|
235
|
254
|
def download_image_finished(self, image_path, image_url, result):
|
236
|
255
|
self.downloading -= 1
|
|
@@ -311,7 +330,7 @@ class MainScreen(Screen):
|
311
|
330
|
data = self.current[1]
|
312
|
331
|
source = data.split("::")[0]
|
313
|
332
|
if self.sources.is_video(data) and "get_info" in dir(self.sources.plugins[source]):
|
314
|
|
- self.sources.plugins
|
|
333
|
+ #self.sources.plugins
|
315
|
334
|
try:
|
316
|
335
|
nfo = self.sources.get_info(self.current[1])
|
317
|
336
|
except Exception, e:
|
|
@@ -344,8 +363,11 @@ class MainScreen(Screen):
|
344
|
363
|
self.show_content(new_content)
|
345
|
364
|
|
346
|
365
|
def back(self):
|
347
|
|
- self["list"].setIndex(0)
|
348
|
|
- self.ok()
|
|
366
|
+ if self.history:
|
|
367
|
+ self["list"].setIndex(0)
|
|
368
|
+ self.ok()
|
|
369
|
+ else:
|
|
370
|
+ self.cancel()
|
349
|
371
|
|
350
|
372
|
def show_content(self,content,index=0):
|
351
|
373
|
self["list"].setList(content)
|
|
@@ -1168,7 +1190,7 @@ class StreamInfo(Screen):
|
1168
|
1190
|
fname = image_url.replace(":", "-").replace("/", "_")
|
1169
|
1191
|
image_path = os.path.join(config.plugins.playstream.tmp_dir.value, fname)
|
1170
|
1192
|
if not os.path.exists(image_path):
|
1171
|
|
- downloadPage(image_url, image_path).addCallback(boundFunction(self.download_finished, image_path,image_url)).addErrback(boundFunction(self.download_failed, image_path,image_url))
|
|
1193
|
+ downloadPage(image_url, image_path, CustomContextFactory(image_url.split("/")[2])).addCallback(boundFunction(self.download_finished, image_path,image_url)).addErrback(boundFunction(self.download_failed, image_path,image_url))
|
1172
|
1194
|
else:
|
1173
|
1195
|
self.download_finished(image_path, image_url)
|
1174
|
1196
|
elif image_url:
|
|
@@ -1178,7 +1200,10 @@ class StreamInfo(Screen):
|
1178
|
1200
|
def download_finished(self, image_path,image_url):
|
1179
|
1201
|
sc = AVSwitch().getFramebufferScale()
|
1180
|
1202
|
self.picloads = ePicLoad()
|
1181
|
|
- self.picloads.PictureData.get().append(boundFunction(self.finish_decode, image_path))
|
|
1203
|
+ try:
|
|
1204
|
+ self.picloads.PictureData.get().append(boundFunction(self.finish_decode, image_path))
|
|
1205
|
+ except:
|
|
1206
|
+ self.picloads.PictureData.connect(boundFunction(self.finish_decode, image_path))
|
1182
|
1207
|
# 0=Width 1=Height 2=Aspect 3=use_cache 4=resize_type 5=Background(#AARRGGBB)
|
1183
|
1208
|
self.picloads.setPara((self["pic"].instance.size().width(), self["pic"].instance.size().height(),
|
1184
|
1209
|
sc[0], sc[1], True, 0, "#00000000"))
|