Ivars 7 年前
父节点
当前提交
2f4228ecd5
共有 6 个文件被更改,包括 34 次插入5 次删除
  1. 29
    3
      addon.py
  2. 1
    1
      addon.xml
  3. 二进制
      release/plugin.video.playstream-0.1.27.zip
  4. 0
    0
      resources/lib/sources/__init__.py
  5. 3
    0
      resources/lib/sources/config.py
  6. 1
    1
      version.txt

+ 29
- 3
addon.py 查看文件

@@ -1,13 +1,30 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 import os,os.path,sys, urllib, traceback
3
-from kodiswift import Plugin, ListItem
3
+try:
4
+    import cPickle as pickle2
5
+except:
6
+    import pickle
7
+import pickle
8
+from kodiswift import Plugin, ListItem, storage
4 9
 from kodiswift import xbmc, xbmcgui, xbmcplugin, xbmcvfs, CLI_MODE
5 10
 from resources.lib import ContentSources, util
11
+sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)),"resources","lib","sources"))
6 12
 
7 13
 plugin = Plugin()
8 14
 plugin.load_addon_settings()
15
+use_storage = False # TODO parametrs settingos + vajag nočekot vai nav labāk lietot pickle
16
+#storage_path = os.path.join(plugin.storage_path,"sources.p")
17
+if use_storage:
18
+    storage = plugin.get_storage("playstream","pickle",ttl=30)
19
+
20
+if use_storage and "sources" in storage:
21
+    print "Restore sources from storage"
22
+    sources = storage["sources"]
23
+# if use_storage and os.path.exists(storage_path): #"sources" in storage:
24
+    #sources = pickle.load(open(storage_path,"rb"))
25
+else:
26
+    sources = ContentSources.ContentSources(os.path.join(os.path.dirname(__file__),"resources","lib","sources"))
9 27
 
10
-sources = ContentSources.ContentSources(os.path.join(os.path.dirname(__file__),"resources","lib","sources"))
11 28
 for source in sources.plugins:
12 29
     if not ("options" in dir(sources.plugins[source]) and sources.plugins[source].options): continue
13 30
     options = sources.plugins[source].options
@@ -56,6 +73,10 @@ def main():
56 73
             return []
57 74
         #xbmc.executebuiltin('Container.SetViewMode(500)')
58 75
         plugin.set_view_mode(50)
76
+        if use_storage:
77
+            print "Save sources to storage"
78
+            storage["sources"] = sources
79
+            storage.sync()
59 80
         return items
60 81
 
61 82
 def get_list(data):
@@ -122,4 +143,9 @@ if __name__ == '__main__':
122 143
         from kodiswift.cli.cli import main as start
123 144
         start()
124 145
     else:
125
-        plugin.run()
146
+        plugin.run()
147
+        if use_storage:
148
+            storage["sources"] = sources
149
+            storage.sync()
150
+            print "Save sources to storage"
151
+            #pickle.dump(sources,open(storage_path,"wb"),pickle.HIGHEST_PROTOCOL)

+ 1
- 1
addon.xml 查看文件

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

二进制
release/plugin.video.playstream-0.1.27.zip 查看文件


+ 0
- 0
resources/lib/sources/__init__.py 查看文件


+ 3
- 0
resources/lib/sources/config.py 查看文件

@@ -53,6 +53,9 @@ class Source(SourceBase):
53 53
         f = open(self.streams_file,"w")
54 54
         for l in self.lists.keys():
55 55
             f.write("[%s]\n"%l)
56
+            t = self.get_title(l)
57
+            if t<>l:
58
+                f.write("%s\n"%t)
56 59
             for item in self.lists[l]:
57 60
                 f.write("%s|%s|%s|%s\n"%(item[0].replace("\n",""),item[1],item[2],item[3].replace("\n","\\n")))
58 61
             f.write("\n")

+ 1
- 1
version.txt 查看文件

@@ -1 +1 @@
1
-0.1.26
1
+0.1.27