def handlePluginShare(args): sourceID = args.get('path','').split('://',1)[-1].split('/',1)[0] page = '' videoID = '' if 'youtube' in sourceID: videoID = args.get('path','').split('videoid=',1)[-1].split('&')[0] page = 'http://youtu.be/%s' % videoID elif 'revision3' in sourceID: url_split = args.get('imagepath','').rsplit('/',1)[-1].split('--') page = 'http://revision3.com/{0}/{1}'.format(url_split[0],url_split[2]) elif 'dailymotion_com' in sourceID: videoID = args.get('path','').split('url=',1)[-1].split('&')[0] page = 'http://www.dailymotion.com/video/%s' % videoID elif 'metacafe' in sourceID: videoID = args.get('path').rsplit('/',1)[-1] page = "http://www.metacafe.com/w/%s" % videoID ''' {'imagepath': 'http://s1.dmcdn.net/CuJ4C/x240-wPZ.jpg', 'addonName': '', 'title': 'H-E05-1', 'filename': '', 'ignore': 'script.module.sharesocial', 'apiver': '1', 'ext': 'plugin', 'addonID': 'skin.confluence', 'path': 'plugin://plugin.video.dailymotion_com/?url=x16ec11&mode=playVideo', 'folder': 'plugin://plugin.video.dailymotion_com/?mode=listVideos&url=https%3a%2f%2fapi.dailymotion.com%2fvideos%3ffields%3ddescription%2cduration%2cid%2cowner.username%2ctaken_time%2cthumbnail_large_url%2ctitle%2cviews_total%26channel%3dfun%26sort%3dcommented-today%26limit%3d50%26family_filter%3d1%26localization%3den_EN%26page%3d1', 'label': 'H-E05-1'} {'imagepath': 'http://s1.mcstatic.com/thumb/11096432/28740650/4/videos/0/1/comedy_bang_bang_reggie_makes_music_jessica_alba_season_2.jpg?v=1', 'addonName': '', 'title': '', 'filename': 'hl-60280229', 'ignore': 'script.module.sharesocial', 'apiver': '1', 'ext': 'plugin', 'addonID': 'skin.confluence', 'path': 'plugin://plugin.video.metacafe/video/hl-60280229', 'folder': 'plugin://plugin.video.metacafe/videos/%2Ff%2Fvideos_about%2Fcomedy%2F/', 'label': 'Comedy Bang! Bang! - Reggie Makes Music: Jessica Alba Season: 2'} ''' else: print args return None share = ShareSocial.getShare(sourceID,'video') share.name = args.get('addonName','Share Social') share.title = share.name + ' Video' share.page = page share.thumbnail = args.get('imagepath') share.share()
def updateStatus(): if not ShareSocial.shareTargetAvailable('status','script.module.sharesocial'): xbmcgui.Dialog().ok('Failed','No status update targets available.') return share = ShareSocial.getShare('script.module.sharesocial', 'status') share.askMessage('Enter Status Message') if not share.message: return share.share(withall=True)
def provide(self,getObject,ID=None): session = TwitterSession(ID=ID,require_existing_user=True) if not session.twit: return getObject.error('NOUSERS') user = {'id':session.user.ID,'name':session.user.name,'photo':session.user.photo} if getObject.type == 'feed': results = session.twit.get_home_timeline(include_entities=1) for r in results: try: text = r.get('text','ERROR') except: print results #print '%s : %s' % (r.get('id'),text) username = r['user'].get('name','ERROR') userimage = r['user'].get('profile_image_url') timestamp = r.get('created_at') textimage = '' ent = r.get('entities') commsObj = None share = None if ent: #print ent media = ent.get('media') urls = ent.get('urls') if media: if media[0].get('type') == 'photo': textimage = media[0].get('media_url') share = ShareSocial.getShare('script.module.sharesocial', 'image') share.media = textimage share.page = media[0].get('expanded_url') share.title = "From Twitter via XBMC" share.thumbnail = textimage #print textimage #print media[0].get('expanded_url') #print media[0].get('url') #print media[0].get('display_url') elif urls: url = urls[0].get('expanded_url') video = StreamExtractor.getVideoInfo(url) if video: textimage = video.thumbnail vid_title = '' if video.title: vid_title = video.title + ': ' share = ShareSocial.getShare('script.module.sharesocial', 'video') share.media = video.streamURL() #print share.media share.page = url share.title = "%sFrom %s via Twitter via XBMC" % (vid_title,video.sourceName) share.thumbnail = textimage if not share.media: share.callbackData = {'source':video.sourceName,'id':video.ID,'page':url} # else: # share = ShareSocial.getShare('script.module.sharesocial', 'image') # share.media = textimage # share.page = url # share.title = "%sFrom %s via Twitter via XBMC" % (vid_title,video.sourceName) # share.thumbnail = textimage replyToID = r.get('in_reply_to_status_id') if replyToID: commsObj = getObject.getCommentsList() commsObj.count = 1 commsObj.isReplyTo = True commsObj.callbackDict['replyToID'] = replyToID getObject.addItem(username,userimage,text,timestamp,textimage,comments=commsObj,client_user=user,share=share) return getObject
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)