|
@@ -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)
|