def processSkinShare(): LOG('Sharing From Plugin ') argNames = ['ignore','apiver','addonID','addonName','ext','imagepath','title','folder','filename','label','path'] args = {} for s in sys.argv: if not argNames: break argName = argNames.pop(0) args[argName] = s if args['ext'] == 'plugin': handlePluginShare(args) return path = args.get('folder','') + args.get('filename','') # Because some paths get screwed up from the filenameandpath infolabel if 'plugin://' in path: path = args.get('path','') # Because we need this for the URL print 'Test: %s' % args print sys.argv shareType = None if args.get('imagepath'): shareType = 'imagefile' path = args.get('imagepath','') LOG('shareType: %s - determined by PicturePath' % shareType) else: ext = args.get('ext') if ext: shareType = getTypeFromExt(ext) if shareType: LOG('shareType: %s - determined by FileExtension' % shareType) else: shareType = getTypeFromFolderPath(args.get('folderpath')) if shareType: LOG('shareType: %s - determined from FolderPath' % shareType) else: shareType = askType() if shareType: LOG('shareType: %s - determined by asking user' % shareType) else: return share = ShareSocial.getShare(args['addonID'], shareType) share.title = args.get('title') or args.get('label') or args.get('filename','') share.media = path share.sourceName = args.get('addonName') lpath = None if share.shareType in ('imagefile','videofile','audiofile'): #TODO: check for cahed file before deciding it's remote if share.mediaIsRemote(): LOG('Share is media and remote.') if share.mediaIsWeb(): LOG('Share is media and on the web. Looking for local copy...') lpath = ShareSocial.getCachedPath(share.media) if lpath: LOG('Found cached content') else: LOG('Not cached - downloading...') targetPath = os.path.join(ShareSocial.CACHE_PATH,'tempmediafile.' + args.get('ext','')) try: global DIALOG DIALOG = xbmcgui.DialogProgress() DIALOG.create('Download','Waiting for download...') DIALOG.update(0,'Waiting for download...') lpath = ShareSocial.getFile(share.media, targetPath, progressCallback) except: error = ERROR('Download failed!') xbmcgui.Dialog().ok('Failed','Download failed.', error) return finally: DIALOG.close() if lpath: LOG('Converting content to local file') alt = share.getCopy() alt.shareType = alt.shareType.replace('file','') share.media = lpath share.addAlternate(alt) else: LOG('Could not download content - changing type to %s' % share.shareType.replace('file','')) share.shareType = share.shareType.replace('file','') else: LOG('Share is media and on the local network. Looking for local copy...') lpath = ShareSocial.getCachedPath(share.media) if lpath: LOG('Found cached content') else: LOG('Not cached - copying to local filesystem...') lpath = os.path.join(ShareSocial.CACHE_PATH,'tempmediafile.' + args.get('ext','')) got = copyRemote(share.media,lpath) if not got: LOG('Failed to copy remote file') lpath = None if lpath: share.media = lpath else: xbmcgui.Dialog().ok('Failed','Unable to share remote file.') return share.share() clearDirFiles(ShareSocial.CACHE_PATH)
def showImage(self,source): target_path = os.path.join(ShareSocial.CACHE_PATH,'slideshow') if not os.path.exists(target_path): os.makedirs(target_path) ShareSocial.clearDirFiles(target_path) ShareSocial.getFile(source,os.path.join(target_path,'image.jpg')) xbmc.executebuiltin('SlideShow(%s)' % target_path)