From d846cffd80d372ff5793663764c1d51efb1335f4 Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Mon, 30 Jan 2017 12:51:36 -0600 Subject: [PATCH 1/2] add tinyurl library and --- resources/lib/tinyurl.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 resources/lib/tinyurl.py diff --git a/resources/lib/tinyurl.py b/resources/lib/tinyurl.py new file mode 100644 index 0000000..35e6c92 --- /dev/null +++ b/resources/lib/tinyurl.py @@ -0,0 +1,11 @@ +import urllib2 + +#this is duplicated in snipppets of code from all over the web, credit to no one +#in particular - to all those that have gone before me! +def shorten(aUrl): + tinyurl = 'http://tinyurl.com/api-create.php?url=' + req = urllib2.urlopen(tinyurl + aUrl) + data = req.read() + + #should be a tiny url + return str(data) From 8edaae803b8d5102bf80acb25930ac04076fea93 Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Mon, 30 Jan 2017 12:51:50 -0600 Subject: [PATCH 2/2] use tinyurl for oauth urls --- resources/language/English/strings.xml | 6 ++++-- resources/lib/vfs.py | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index c6d4e5e..6a315a8 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -47,8 +47,8 @@ Writing file Starting scheduled backup Removing backup - Check log for Dropbox authorize URL - Click OK when authorized + Go to this URL to authorize + Click OK AFTER completion Dropbox Developer Code Needed Visit https://www.dropbox.com/developers Enable Scheduler @@ -93,4 +93,6 @@ Open Settings Extracting Archive Error extracting the zip archive + Click OK to enter code + Google Drive Validation Code diff --git a/resources/lib/vfs.py b/resources/lib/vfs.py index f5511cf..8e8475c 100644 --- a/resources/lib/vfs.py +++ b/resources/lib/vfs.py @@ -1,4 +1,5 @@ import utils as utils +import tinyurl as tinyurl import xbmc import xbmcvfs import xbmcgui @@ -135,14 +136,14 @@ class DropboxFileSystem(Vfs): user_token_key,user_token_secret = self.getToken() sess = session.DropboxSession(self.APP_KEY,self.APP_SECRET,"app_folder") - utils.log("token:" + user_token_key + ":" + user_token_secret) + if(user_token_key == '' and user_token_secret == ''): token = sess.obtain_request_token() url = sess.build_authorize_url(token) #print url in log utils.log("Authorize URL: " + url) - xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30056),utils.getString(30057)) + xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30056),utils.getString(30057),tinyurl.shorten(url)) #if user authorized this will work user_token = sess.obtain_access_token(token) @@ -304,7 +305,8 @@ class GoogleDriveFilesystem(Vfs): utils.log("Google Drive Authorize URL: " + drive_url) - code = xbmcgui.Dialog().input('Google Drive Validation Code','Input the Validation code after authorizing this app') + xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30056),utils.getString(30102),tinyurl.shorten(drive_url)) + code = xbmcgui.Dialog().input(utils.getString(30103)) gauth.Auth(code) gauth.SaveCredentialsFile(xbmc.validatePath(xbmc.translatePath(utils.data_dir() + 'google_drive.dat')))