2012-10-26 16:42:10 +02:00
|
|
|
import utils as utils
|
2012-11-02 21:59:40 +01:00
|
|
|
import xbmcvfs
|
2012-11-04 21:39:17 +01:00
|
|
|
import xbmcgui
|
2012-11-02 21:59:40 +01:00
|
|
|
from dropbox import client, rest, session
|
|
|
|
|
|
|
|
APP_KEY = 'f5wlmek6aoriqax'
|
|
|
|
APP_SECRET = 'b1461sje1kxgzet'
|
2012-10-26 16:42:10 +02:00
|
|
|
|
|
|
|
class Vfs:
|
2012-11-04 21:39:17 +01:00
|
|
|
root_path = None
|
2012-10-26 16:42:10 +02:00
|
|
|
|
2012-11-04 21:39:17 +01:00
|
|
|
def set_root(self,rootString):
|
|
|
|
self.root_path = rootString
|
|
|
|
|
|
|
|
#fix slashes
|
|
|
|
self.root_path = self.root_path.replace("\\","/")
|
|
|
|
|
|
|
|
#check if trailing slash is included
|
|
|
|
if(self.root_path[-1:] != "/"):
|
|
|
|
self.root_path = self.root_path + "/"
|
|
|
|
|
|
|
|
def listdir(self,directory):
|
2012-10-26 16:42:10 +02:00
|
|
|
return {}
|
|
|
|
|
2012-11-04 21:39:17 +01:00
|
|
|
def mkdir(self,directory):
|
2012-10-26 16:42:10 +02:00
|
|
|
return True
|
|
|
|
|
2012-11-04 21:39:17 +01:00
|
|
|
def copy(self,source,dest):
|
2012-10-26 16:42:10 +02:00
|
|
|
return True
|
2012-11-02 21:59:40 +01:00
|
|
|
|
2012-11-04 21:39:17 +01:00
|
|
|
def rmdir(self,directory):
|
2012-11-02 21:59:40 +01:00
|
|
|
return True
|
|
|
|
|
2012-11-04 21:39:17 +01:00
|
|
|
def exists(self,aFile):
|
2012-11-02 21:59:40 +01:00
|
|
|
return True
|
2012-10-26 16:42:10 +02:00
|
|
|
|
2012-11-02 21:59:40 +01:00
|
|
|
class XBMCFileSystem(Vfs):
|
2012-11-04 21:39:17 +01:00
|
|
|
|
|
|
|
def listdir(self,directory):
|
2012-11-02 21:59:40 +01:00
|
|
|
return xbmcvfs.listdir(directory)
|
|
|
|
|
2012-11-04 21:39:17 +01:00
|
|
|
def mkdir(self,directory):
|
2012-11-02 21:59:40 +01:00
|
|
|
return xbmcvfs.mkdir(directory)
|
|
|
|
|
2012-11-04 21:39:17 +01:00
|
|
|
def copy(self,source,dest):
|
|
|
|
return xbmcvfs.copy(source,dest)
|
|
|
|
|
|
|
|
def rmdir(self,directory):
|
2012-11-02 21:59:40 +01:00
|
|
|
return xbmcvfs.rmdir(directory,True)
|
|
|
|
|
2012-11-04 21:39:17 +01:00
|
|
|
def exists(self,aFile):
|
2012-11-02 21:59:40 +01:00
|
|
|
return xbmcvfs.exists(aFile)
|
|
|
|
|
2012-11-04 21:39:17 +01:00
|
|
|
class DropboxFileSystem(Vfs):
|
|
|
|
user_token = None
|
|
|
|
|
2012-11-02 21:59:40 +01:00
|
|
|
def __init__(self):
|
2012-11-04 21:39:17 +01:00
|
|
|
self.user_token = utils.getSetting('dropbox_token')
|
|
|
|
sess = session.DropboxSession(APP_KEY,APP_SECRET,"app_folder")
|
|
|
|
|
|
|
|
if(self.user_token == ''):
|
|
|
|
token = sess.obtain_request_token()
|
|
|
|
url = sess.build_authorize_url(token)
|
|
|
|
try:
|
|
|
|
self.user_token = sess.obtain_access_token(token)
|
|
|
|
utils.setSetting("dropbox_token",self.user_token)
|
|
|
|
except:
|
|
|
|
xbmcgui.Dialog().ok(utils.getString(30010),"Authorize Dropbox URL, also in log",url)
|
|
|
|
utils.log("Authorize URL: " + url)
|
|
|
|
|
|
|
|
self.client = client.DropboxClient(sess)
|
|
|
|
utils.log(self.client.account_info())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|