Ivars 7 years ago
parent
commit
2f4228ecd5

+ 29
- 3
addon.py View File

1
 # -*- coding: utf-8 -*-
1
 # -*- coding: utf-8 -*-
2
 import os,os.path,sys, urllib, traceback
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
 from kodiswift import xbmc, xbmcgui, xbmcplugin, xbmcvfs, CLI_MODE
9
 from kodiswift import xbmc, xbmcgui, xbmcplugin, xbmcvfs, CLI_MODE
5
 from resources.lib import ContentSources, util
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
 plugin = Plugin()
13
 plugin = Plugin()
8
 plugin.load_addon_settings()
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
 for source in sources.plugins:
28
 for source in sources.plugins:
12
     if not ("options" in dir(sources.plugins[source]) and sources.plugins[source].options): continue
29
     if not ("options" in dir(sources.plugins[source]) and sources.plugins[source].options): continue
13
     options = sources.plugins[source].options
30
     options = sources.plugins[source].options
56
             return []
73
             return []
57
         #xbmc.executebuiltin('Container.SetViewMode(500)')
74
         #xbmc.executebuiltin('Container.SetViewMode(500)')
58
         plugin.set_view_mode(50)
75
         plugin.set_view_mode(50)
76
+        if use_storage:
77
+            print "Save sources to storage"
78
+            storage["sources"] = sources
79
+            storage.sync()
59
         return items
80
         return items
60
 
81
 
61
 def get_list(data):
82
 def get_list(data):
122
         from kodiswift.cli.cli import main as start
143
         from kodiswift.cli.cli import main as start
123
         start()
144
         start()
124
     else:
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 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.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
   <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" />

BIN
release/plugin.video.playstream-0.1.27.zip View File


+ 0
- 0
resources/lib/sources/__init__.py View File


+ 3
- 0
resources/lib/sources/config.py View File

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

+ 1
- 1
version.txt View File

1
-0.1.26
1
+0.1.27