Browse Source

pielikts klāt XTV.lv

Ivars 5 years ago
parent
commit
0d69a412a5
6 changed files with 594 additions and 523 deletions
  1. 10
    13
      addon.py
  2. 1
    1
      addon.xml
  3. 14
    1
      changelog.md
  4. 36
    9
      context_download.py
  5. 1
    1
      kmake.bat
  6. 532
    498
      project.wpr

+ 10
- 13
addon.py View File

41
 use_streams_file_remote = plugin.get_setting("general_use_streams_file_remote",bool)
41
 use_streams_file_remote = plugin.get_setting("general_use_streams_file_remote",bool)
42
 download_overwrite = plugin.get_setting("general_download_overwrite",bool)
42
 download_overwrite = plugin.get_setting("general_download_overwrite",bool)
43
 
43
 
44
-
45
 #storage_path = os.path.join(plugin.storage_path,"sources.p")
44
 #storage_path = os.path.join(plugin.storage_path,"sources.p")
46
 if use_storage:
45
 if use_storage:
47
     try:
46
     try:
74
 else:
73
 else:
75
     print "[playstream] Create sources objects"
74
     print "[playstream] Create sources objects"
76
     if use_streams_file_remote:
75
     if use_streams_file_remote:
77
-        try:
78
-            sources = ContentSources.ContentSources(sources_directory, streams_file_remote)
79
-        except Exception as e:
80
-            try:
81
-                sources = ContentSources.ContentSources(sources_directory, streams_file)
82
-                plugin.notify("Remote streams file is not available, fallback to local")
83
-            except Exception as e:
84
-                plugin.notify(e.message)
76
+        cfg_file = streams_file_remote
77
+        cfg_file2 = streams_file
85
     else:
78
     else:
86
-        try:
87
-            sources = ContentSources.ContentSources(sources_directory, streams_file)
88
-        except Exception as e:
89
-            plugin.notify(e.message)
79
+        cfg_file = streams_file
80
+        cfg_file2 = None
81
+    try:
82
+        sources = ContentSources.ContentSources(sources_directory, cfg_file, cfg_file2)
83
+    except Exception as e:
84
+        xbmc.executebuiltin("Notification(Error,%s" % e.message)
85
+        xbmc.executebuiltin("XBMC.ActivateWindow(Home)")
86
+    #plugin.notify("Using streams file '%s'" % sources.plugins["config"].streams_file)
90
 
87
 
91
 for source in sources.plugins:
88
 for source in sources.plugins:
92
     if not ("options" in dir(sources.plugins[source]) and sources.plugins[source].options): continue
89
     if not ("options" in dir(sources.plugins[source]) and sources.plugins[source].options): continue

+ 1
- 1
addon.xml View File

1
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
-<addon version="0.1.95" id="plugin.video.playstream" name="PlayStream" provider-name="ivars777"  >
2
+<addon version="0.1.99" id="plugin.video.playstream" name="PlayStream" provider-name="ivars777"  >
3
   <requires>
3
   <requires>
4
     <import addon="xbmc.python" version="2.1.0"/>
4
     <import addon="xbmc.python" version="2.1.0"/>
5
     <import addon="script.module.requests" />
5
     <import addon="script.module.requests" />

+ 14
- 1
changelog.md View File

1
-**0.1.94** (12.10.2018):
1
+**0.1.98** (26.01.2019):
2
+- [feature] pielikts klāt XTV.lv
3
+
4
+**0.1.98** (23.12.2018):
5
+- [fix] salabots filmix, tvplay
6
+
7
+**0.1.97** (05.12.2018):
8
+- [fix] pielabots ltc arhīvs (bildes, kārtība nfo)
9
+- [fix] download pielabots
10
+
11
+**0.1.96** (02.11.2018):
12
+- [fix] papildināts lmt (delfi video)
13
+
14
+**0.1.94** (12.10   .2018):
2
 - [fix] salabots replay
15
 - [fix] salabots replay
3
 
16
 
4
 **0.1.94** (04.09.2018):
17
 **0.1.94** (04.09.2018):

+ 36
- 9
context_download.py View File

18
 #from twisted.internet import reactor, defer
18
 #from twisted.internet import reactor, defer
19
 
19
 
20
 plugin = Plugin(addon_id="plugin.video.playstream")
20
 plugin = Plugin(addon_id="plugin.video.playstream")
21
+prefix = "plugin://%s/" % plugin.id
21
 #plugin.load_addon_settings()
22
 #plugin.load_addon_settings()
22
 use_storage = plugin.get_setting("general_use_storage",bool) # TODO vajag nočekot vai nav labāk lietot pickle
23
 use_storage = plugin.get_setting("general_use_storage",bool) # TODO vajag nočekot vai nav labāk lietot pickle
24
+storage_ttl = plugin.get_setting("general_ttl",int)
25
+use_proxy = plugin.get_setting("general_proxy_use",bool)
26
+proxy_url = plugin.get_setting("general_proxy_url",str)
27
+playlist = plugin.get_setting("general_playlist",str)
28
+#download_dir = plugin.get_setting("general_download_dir",str)
29
+view_mode = plugin.get_setting("general_view_mode",str)
30
+streams_file = plugin.get_setting("general_streams_file",str)
31
+streams_file_remote = plugin.get_setting("general_streams_file_remote",str)
32
+use_streams_file_remote = plugin.get_setting("general_use_streams_file_remote",bool)
23
 overwrite = plugin.get_setting("general_download_overwrite",bool)
33
 overwrite = plugin.get_setting("general_download_overwrite",bool)
34
+
24
 sleep_time = 5  # TODO jāliek iekš parametriem
35
 sleep_time = 5  # TODO jāliek iekš parametriem
25
 
36
 
26
 cunicode = lambda s: s.decode("utf8") if isinstance(s, str) else s
37
 cunicode = lambda s: s.decode("utf8") if isinstance(s, str) else s
28
 
39
 
29
 #print "argv=",sys.argv
40
 #print "argv=",sys.argv
30
 cmd = sys.argv[1]
41
 cmd = sys.argv[1]
31
-title = sys.argv[2]
32
-data = sys.argv[3]
33
-download_dir = sys.argv[4]
42
+title = urllib.unquote(sys.argv[2])
43
+data = urllib.unquote(sys.argv[3])
44
+download_dir = urllib.unquote(sys.argv[4])
34
 #overwrite = sys.argv[5] if len(sys.argv)>5 else False
45
 #overwrite = sys.argv[5] if len(sys.argv)>5 else False
35
 
46
 
36
 queue_dir = os.path.join(xbmc.translatePath("special://temp"), "download_queue") if not CLI_MODE else "download_queue"
47
 queue_dir = os.path.join(xbmc.translatePath("special://temp"), "download_queue") if not CLI_MODE else "download_queue"
54
 
65
 
55
 cur_directory = os.path.dirname(__file__)
66
 cur_directory = os.path.dirname(__file__)
56
 sources_directory = os.path.join(cur_directory,"resources","lib", "content", "sources")
67
 sources_directory = os.path.join(cur_directory,"resources","lib", "content", "sources")
57
-sources = ContentSources.ContentSources(sources_directory)
58
-
68
+#sources = ContentSources.ContentSources(sources_directory)
69
+#print "[playstream] Create sources objects"
70
+if use_streams_file_remote:
71
+    cfg_file = streams_file_remote
72
+    cfg_file2 = streams_file
73
+else:
74
+    cfg_file = streams_file
75
+    cfg_file2 = None
76
+try:
77
+    sources = ContentSources.ContentSources(sources_directory, cfg_file, cfg_file2)
78
+except Exception as e:
79
+    #xbmc.executebuiltin("Notification(Error,%s" % e.message)
80
+    #xbmc.executebuiltin("XBMC.ActivateWindow(Home)")
81
+    plugin.notify(e.message)
59
 
82
 
60
 def main():
83
 def main():
61
     if not sources.is_video(data):  # Folderis
84
     if not sources.is_video(data):  # Folderis
96
         stream = streams[res]
119
         stream = streams[res]
97
     else:
120
     else:
98
         stream = streams[0]
121
         stream = streams[0]
99
-
100
-    download_stream(stream, download_dir, overwrite, notify, num=num)
122
+    try:
123
+        download_stream(stream, download_dir, overwrite, notify, num=num)
124
+    except Exception as e:
125
+        notify(e.message, title="Error")
101
 
126
 
102
     #d = Downloader.download_video(stream["url"], os.path.join(download_dir, output), stream["headers"])
127
     #d = Downloader.download_video(stream["url"], os.path.join(download_dir, output), stream["headers"])
103
     #reactor.run()
128
     #reactor.run()
123
 ####################################################################################################
148
 ####################################################################################################
124
 
149
 
125
 def download_stream(stream, download_dir, overwrite=True, cb_notify=None, num=False):
150
 def download_stream(stream, download_dir, overwrite=True, cb_notify=None, num=False):
151
+    UA = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0"
152
+
126
     #output =  stream["name"].replace("\\"," ").replace(":"," ").replace("|"," ")
153
     #output =  stream["name"].replace("\\"," ").replace(":"," ").replace("|"," ")
127
     url = stream["url"]
154
     url = stream["url"]
128
     title = stream["name"].strip()
155
     title = stream["name"].strip()
129
     output = file.make_fname(title)
156
     output = file.make_fname(title)
130
 
157
 
131
-    headers = stream["headers"] if "headers" in stream and stream["headers"] else {"user-agent":"Enigma2"}
158
+    headers = stream["headers"] if "headers" in stream and stream["headers"] else {"user-agent":UA}
132
     try:
159
     try:
133
         h = get_header(url,headers=headers)
160
         h = get_header(url,headers=headers)
134
         mtype = h.get("content-type")
161
         mtype = h.get("content-type")
327
         progress = float(currentbytes)/float(totalbytes)*100
354
         progress = float(currentbytes)/float(totalbytes)*100
328
         msg = "%.1f%% (%iMB/%iMB)"%(progress,currentbytes / 1024 / 1024,totalbytes / 1024 / 1024)
355
         msg = "%.1f%% (%iMB/%iMB)"%(progress,currentbytes / 1024 / 1024,totalbytes / 1024 / 1024)
329
         #print msg
356
         #print msg
330
-        #notify(msg)
357
+        notify(msg)
331
 
358
 
332
         if type == "vod":
359
         if type == "vod":
333
             if ts_num >= len(ts_list) or (limit and currenttime>limit):
360
             if ts_num >= len(ts_list) or (limit and currenttime>limit):

+ 1
- 1
kmake.bat View File

112
 
112
 
113
 if not ()==(%1%) (
113
 if not ()==(%1%) (
114
     git commit -m %ver%
114
     git commit -m %ver%
115
-    git tag -d "%ver%"
115
+    git tag -d %ver%
116
     git tag %ver%
116
     git tag %ver%
117
     git push
117
     git push
118
 
118
 

+ 532
- 498
project.wpr
File diff suppressed because it is too large
View File