def slideshowAlbum(dictlist, name): log("slideshowAlbum") nl = remove_dict_duplicates(dictlist, 'DirectoryItem_url') for e in nl: q.put(e) ev = threading.Event() s = ScreensaverManager(ev, q) try: s.start_loop() except Exception as ex: log(" EXCEPTION slideshowAlbum:=" + str(sys.exc_info()[0]) + " " + str(ex)) return
def slideshowAlbum(dictlist, name): log("slideshowAlbum") nl = remove_dict_duplicates( dictlist, 'DirectoryItem_url') for e in nl: q.put(e) ev=threading.Event() s= ScreensaverManager(ev,q) try: s.start_loop() except Exception as ex: log(" EXCEPTION slideshowAlbum:="+ str( sys.exc_info()[0]) + " " + str(ex) ) return
def autoSlideshow(url, name, type_): log('starting slideshow ' + url) ev = threading.Event() entries = [] #watchdog_counter=0 preview_w = 0 preview_h = 0 image = '' #content = opener.open(url).read() content = reddit_request(url) if not content: return #log( str(content) ) #content = json.loads(content.replace('\\"', '\'')) content = json.loads(content) log("slideshow %s:Parsing %d items: %s" % (type_, len(content['data']['children']), 'random' if random_post_order else 'normal order')) data_children = content['data']['children'] if random_post_order: random.shuffle(data_children) for j_entry in data_children: try: title = unescape(j_entry['data']['title'].encode('utf-8')) log(" TITLE:%s [r/%s]" % (title, j_entry.get('data').get('subreddit'))) try: description = unescape(j_entry['data']['media']['oembed'] ['description'].encode('utf-8')) except: description = '' #log(' description [%s]' %description) try: post_selftext = unescape( j_entry['data']['selftext'].encode('utf-8')) except: post_selftext = '' #log(' post_selftext[%s]' %post_selftext) description = post_selftext + '[CR]' + description if post_selftext else description try: media_url = j_entry['data']['url'] except: media_url = j_entry['data']['media']['oembed']['url'] try: preview = j_entry['data']['preview']['images'][0]['source'][ 'url'].encode('utf-8').replace('&', '&') try: preview_h = float(j_entry['data']['preview']['images'][0] ['source']['height']) preview_w = float(j_entry['data']['preview']['images'][0] ['source']['width']) except: preview_w = 0 preview_h = 0 except Exception as e: #log(" getting preview image EXCEPTION:="+ str( sys.exc_info()[0]) + " " + str(e) ) preview = "" ld = parse_reddit_link(link_url=media_url, assume_is_video=False, needs_preview=True, get_playable_url=True) if ld: if not preview: preview = ld.poster if (addon.getSetting('include_albums') == 'true') and (ld.media_type == sitesBase.TYPE_ALBUM): dictlist = listAlbum(media_url, title, 'return_dictlist') for d in dictlist: #log(' (S) adding items from album ' + title +' ' + d.get('DirectoryItem_url') ) t2 = d.get('li_label') if d.get('li_label') else title #entries.append([ t2, d.get('DirectoryItem_url'), d.get('width'), d.get('height'), len(entries)]) d['li_label'] = t2 entries.append(d) #title='' #only put the title in once. else: if addon.getSetting('use_reddit_preview') == 'true': if preview: image = preview elif ld.poster: image = ld.poster #if preview: entries.append([title,preview,preview_w, preview_h,len(entries)]) #log(' (N)added preview:%s %s' %( title,preview) ) #elif ld.poster: entries.append([title,ld.poster,preview_w, preview_h,len(entries)]) #log(' (N)added poster:%s %s' % ( title,ld.poster) ) else: if ld.poster: image = ld.poster #entries.append([title,ld.poster,preview_w, preview_h,len(entries)]) elif preview: image = preview #entries.append([title,preview,preview_w, preview_h,len(entries)]) #if ld.poster: entries.append([title,ld.poster,preview_w, preview_h,len(entries)]) #elif preview: entries.append([title,preview,preview_w, preview_h,len(entries)]) append_entry(entries, title, image, preview_w, preview_h, description) else: append_entry(entries, title, preview, preview_w, preview_h, description) #log(' (N)added preview:%s' % title ) except Exception as e: log(' autoPlay exception:' + str(e)) #log( repr(entries)) entries = remove_dict_duplicates(entries, 'DirectoryItem_url') # #for i,e in enumerate(entries): log(' e1-%d %s' %(i, e[1]) ) # def k2(x): return x[1] # entries=remove_duplicates(entries, k2) # #for i,e in enumerate(entries): log(' e2-%d %s' %(i, e[1]) ) for i, e in enumerate(entries): log(' possible playable items({0}) {1}...{2}x{3} {4}'.format( i, e['li_label'].ljust(15)[:15], repr(e.get('width')), repr(e.get('height')), e.get('DirectoryItem_url'))) if len(entries) == 0: log(' Play All: no playable items') xbmc.executebuiltin( 'XBMC.Notification("%s","%s")' % (translation(32054), translation(32055))) #Play All No playable items return #if type.endswith("_RANDOM"): # random.shuffle(entries) #for title, url in entries: # log(" added to playlist:"+ title + " " + url ) log("**********playing slideshow*************") for e in entries: q.put(e) #s= HorizontalSlideScreensaver(ev,q) s = ScreensaverManager(ev, q) try: s.start_loop() except Exception as e: log(" EXCEPTION slideshowAlbum:=" + str(sys.exc_info()[0]) + " " + str(e)) return
def slideshowAlbum(dictlist, name): log("slideshowAlbum") #introduce a duplicate # dictlist.append( {'li_label': 'aaa1', # 'li_label2': 'descrip', # 'DirectoryItem_url': 'http://i.imgur.com/K5uhHZF.jpg', # 'li_thumbnailImage': 'media_thumb_url', # 'width': 12, # 'height': 123, # } ) # # dictlist.append( {'li_label': 'aaa2', # 'li_label2': 'descrip', # 'DirectoryItem_url': 'http://i.imgur.com/2C3G23c.jpg', # 'li_thumbnailImage': 'media_thumb_url', # 'width': 12, # 'height': 123, # } ) # # dictlist.append( {'li_label': 'aaa3', # 'li_label2': 'descrip', # 'DirectoryItem_url': 'http://i.imgur.com/DXsb037.jpg', # 'li_thumbnailImage': 'media_thumb_url', # 'width': 12, # 'height': 123, # } ) # # for d in dictlist: # media_url=d.get('DirectoryItem_url') # title =d.get('li_label') if d.get('li_label') else '' # width =d.get('width') # height =d.get('height') # description=d.get('description') # log( " %s... %s " %(title.ljust(15)[:15] ,media_url ) ) nl = remove_dict_duplicates(dictlist, 'DirectoryItem_url') # log("***after***") # for d in nl: # media_url=d.get('DirectoryItem_url') # title =d.get('li_label') if d.get('li_label') else '' # width =d.get('width') # height =d.get('height') # description=d.get('description') # log( " %s... %s " %(title.ljust(15)[:15] ,media_url ) ) for e in nl: q.put(e) ev = threading.Event() #s= HorizontalSlideScreensaver2(ev,q) s = ScreensaverManager(ev, q) try: s.start_loop() except Exception as ex: log(" EXCEPTION slideshowAlbum:=" + str(sys.exc_info()[0]) + " " + str(ex)) return
def autoSlideshow(url, name, type_): log('starting slideshow '+ url) ev=threading.Event() entries = [] #watchdog_counter=0 preview_w=0 preview_h=0 image='' #content = opener.open(url).read() content = reddit_request(url) if not content: return #log( str(content) ) #content = json.loads(content.replace('\\"', '\'')) content = json.loads(content) log("slideshow %s:Parsing %d items: %s" %( type_, len(content['data']['children']), 'random' if random_post_order else 'normal order' ) ) data_children = content['data']['children'] if random_post_order: random.shuffle(data_children) for j_entry in data_children: try: title = unescape(j_entry['data']['title'].encode('utf-8')) log(" TITLE:%s [r/%s]" %( title, j_entry.get('data').get('subreddit') ) ) try: description = unescape(j_entry['data']['media']['oembed']['description'].encode('utf-8')) except: description = '' #log(' description [%s]' %description) try: post_selftext=unescape(j_entry['data']['selftext'].encode('utf-8')) except: post_selftext='' #log(' post_selftext[%s]' %post_selftext) description=post_selftext+'[CR]'+description if post_selftext else description try: media_url = j_entry['data']['url'] except: media_url = j_entry['data']['media']['oembed']['url'] try: preview=j_entry['data']['preview']['images'][0]['source']['url'].encode('utf-8').replace('&','&') try: preview_h = float( j_entry['data']['preview']['images'][0]['source']['height'] ) preview_w = float( j_entry['data']['preview']['images'][0]['source']['width'] ) except: preview_w=0 preview_h=0 except Exception as e: #log(" getting preview image EXCEPTION:="+ str( sys.exc_info()[0]) + " " + str(e) ) preview="" ld=parse_reddit_link(link_url=media_url, assume_is_video=False, needs_preview=True, get_playable_url=True ) if ld: if not preview: preview = ld.poster if (addon.getSetting('include_albums')=='true') and (ld.media_type==sitesBase.TYPE_ALBUM) : dictlist = listAlbum( media_url, title, 'return_dictlist') for d in dictlist: #log(' (S) adding items from album ' + title +' ' + d.get('DirectoryItem_url') ) t2=d.get('li_label') if d.get('li_label') else title #entries.append([ t2, d.get('DirectoryItem_url'), d.get('width'), d.get('height'), len(entries)]) d['li_label']=t2 entries.append( d ) #title='' #only put the title in once. else: if addon.getSetting('use_reddit_preview')=='true': if preview: image=preview elif ld.poster: image=ld.poster #if preview: entries.append([title,preview,preview_w, preview_h,len(entries)]) #log(' (N)added preview:%s %s' %( title,preview) ) #elif ld.poster: entries.append([title,ld.poster,preview_w, preview_h,len(entries)]) #log(' (N)added poster:%s %s' % ( title,ld.poster) ) else: if ld.poster: image=ld.poster #entries.append([title,ld.poster,preview_w, preview_h,len(entries)]) elif preview: image=preview #entries.append([title,preview,preview_w, preview_h,len(entries)]) #if ld.poster: entries.append([title,ld.poster,preview_w, preview_h,len(entries)]) #elif preview: entries.append([title,preview,preview_w, preview_h,len(entries)]) append_entry( entries, title,image,preview_w, preview_h, description ) else: append_entry( entries, title,preview,preview_w, preview_h, description ) #log(' (N)added preview:%s' % title ) except Exception as e: log( ' autoPlay exception:' + str(e) ) #log( repr(entries)) entries = remove_dict_duplicates( entries, 'DirectoryItem_url') # #for i,e in enumerate(entries): log(' e1-%d %s' %(i, e[1]) ) # def k2(x): return x[1] # entries=remove_duplicates(entries, k2) # #for i,e in enumerate(entries): log(' e2-%d %s' %(i, e[1]) ) for i, e in enumerate(entries): log(' possible playable items({0}) {1}...{2}x{3} {4}'.format( i, e['li_label'].ljust(15)[:15], repr(e.get('width')),repr(e.get('height')), e.get('DirectoryItem_url')) ) if len(entries)==0: log(' Play All: no playable items' ) xbmc.executebuiltin('XBMC.Notification("%s","%s")' %(translation(32054), translation(32055) ) ) #Play All No playable items return #if type.endswith("_RANDOM"): # random.shuffle(entries) #for title, url in entries: # log(" added to playlist:"+ title + " " + url ) log("**********playing slideshow*************") for e in entries: q.put(e) #s= HorizontalSlideScreensaver(ev,q) s= ScreensaverManager(ev,q) try: s.start_loop() except Exception as e: log(" EXCEPTION slideshowAlbum:="+ str( sys.exc_info()[0]) + " " + str(e) ) return
def slideshowAlbum(dictlist, name): log("slideshowAlbum") #introduce a duplicate # dictlist.append( {'li_label': 'aaa1', # 'li_label2': 'descrip', # 'DirectoryItem_url': 'http://i.imgur.com/K5uhHZF.jpg', # 'li_thumbnailImage': 'media_thumb_url', # 'width': 12, # 'height': 123, # } ) # # dictlist.append( {'li_label': 'aaa2', # 'li_label2': 'descrip', # 'DirectoryItem_url': 'http://i.imgur.com/2C3G23c.jpg', # 'li_thumbnailImage': 'media_thumb_url', # 'width': 12, # 'height': 123, # } ) # # dictlist.append( {'li_label': 'aaa3', # 'li_label2': 'descrip', # 'DirectoryItem_url': 'http://i.imgur.com/DXsb037.jpg', # 'li_thumbnailImage': 'media_thumb_url', # 'width': 12, # 'height': 123, # } ) # # for d in dictlist: # media_url=d.get('DirectoryItem_url') # title =d.get('li_label') if d.get('li_label') else '' # width =d.get('width') # height =d.get('height') # description=d.get('description') # log( " %s... %s " %(title.ljust(15)[:15] ,media_url ) ) nl = remove_dict_duplicates( dictlist, 'DirectoryItem_url') # log("***after***") # for d in nl: # media_url=d.get('DirectoryItem_url') # title =d.get('li_label') if d.get('li_label') else '' # width =d.get('width') # height =d.get('height') # description=d.get('description') # log( " %s... %s " %(title.ljust(15)[:15] ,media_url ) ) for e in nl: q.put(e) ev=threading.Event() #s= HorizontalSlideScreensaver2(ev,q) s= ScreensaverManager(ev,q) try: s.start_loop() except Exception as ex: log(" EXCEPTION slideshowAlbum:="+ str( sys.exc_info()[0]) + " " + str(ex) ) return
def autoSlideshow(url, name, type_): log('starting slideshow '+ url) ev=threading.Event() entries = [] preview_w=0 preview_h=0 image='' content = reddit_request(url) if not content: return content = json.loads(content) log("slideshow %s:Parsing %d items: %s" %( type_, len(content['data']['children']), 'random' if random_post_order else 'normal order' ) ) data_children = content['data']['children'] if random_post_order: random.shuffle(data_children) for j_entry in data_children: try: title = unescape(j_entry['data']['title'].encode('utf-8')) log(" TITLE:%s [r/%s]" %( title, j_entry.get('data').get('subreddit') ) ) try: description = unescape(j_entry['data']['media']['oembed']['description'].encode('utf-8')) except: description = '' try: post_selftext=unescape(j_entry['data']['selftext'].encode('utf-8')) except: post_selftext='' description=post_selftext+'[CR]'+description if post_selftext else description try: media_url = j_entry['data']['url'] except: media_url = j_entry['data']['media']['oembed']['url'] try: preview=j_entry['data']['preview']['images'][0]['source']['url'].encode('utf-8').replace('&','&') try: preview_h = float( j_entry['data']['preview']['images'][0]['source']['height'] ) preview_w = float( j_entry['data']['preview']['images'][0]['source']['width'] ) except: preview_w=0 preview_h=0 except Exception as e: preview="" ld=parse_reddit_link(link_url=media_url, assume_is_video=False, needs_preview=True, get_playable_url=True ) if ld: if not preview: preview = ld.poster if (addon.getSetting('include_albums')=='true') and (ld.media_type==sitesBase.TYPE_ALBUM) : dictlist = listAlbum( media_url, title, 'return_dictlist') for d in dictlist: t2=d.get('li_label') if d.get('li_label') else title d['li_label']=t2 entries.append( d ) else: if addon.getSetting('use_reddit_preview')=='true': if preview: image=preview elif ld.poster: image=ld.poster else: if ld.poster: image=ld.poster #entries.append([title,ld.poster,preview_w, preview_h,len(entries)]) elif preview: image=preview #entries.append([title,preview,preview_w, preview_h,len(entries)]) append_entry( entries, title,image,preview_w, preview_h, description ) else: append_entry( entries, title,preview,preview_w, preview_h, description ) except Exception as e: log( ' autoPlay exception:' + str(e) ) entries = remove_dict_duplicates( entries, 'DirectoryItem_url') for i, e in enumerate(entries): log(' possible playable items({0}) {1}...{2}x{3} {4}'.format( i, e['li_label'].ljust(15)[:15], repr(e.get('width')),repr(e.get('height')), e.get('DirectoryItem_url')) ) if len(entries)==0: log(' Play All: no playable items' ) xbmc.executebuiltin('XBMC.Notification("%s","%s")' %(translation(32054), translation(32055) ) ) #Play All No playable items return log("**********playing slideshow*************") for e in entries: q.put(e) s= ScreensaverManager(ev,q) try: s.start_loop() except Exception as e: log(" EXCEPTION slideshowAlbum:="+ str( sys.exc_info()[0]) + " " + str(e) ) return
def autoSlideshow(url, name, type_): log('starting slideshow ' + url) ev = threading.Event() entries = [] preview_w = 0 preview_h = 0 image = '' content = reddit_request(url) if not content: return content = json.loads(content) log("slideshow %s:Parsing %d items: %s" % (type_, len(content['data']['children']), 'random' if random_post_order else 'normal order')) data_children = content['data']['children'] if random_post_order: random.shuffle(data_children) for j_entry in data_children: try: title = unescape(j_entry['data']['title'].encode('utf-8')) log(" TITLE:%s [r/%s]" % (title, j_entry.get('data').get('subreddit'))) try: description = unescape(j_entry['data']['media']['oembed'] ['description'].encode('utf-8')) except: description = '' try: post_selftext = unescape( j_entry['data']['selftext'].encode('utf-8')) except: post_selftext = '' description = post_selftext + '[CR]' + description if post_selftext else description try: media_url = j_entry['data']['url'] except: media_url = j_entry['data']['media']['oembed']['url'] try: preview = j_entry['data']['preview']['images'][0]['source'][ 'url'].encode('utf-8').replace('&', '&') try: preview_h = float(j_entry['data']['preview']['images'][0] ['source']['height']) preview_w = float(j_entry['data']['preview']['images'][0] ['source']['width']) except: preview_w = 0 preview_h = 0 except Exception as e: preview = "" ld = parse_reddit_link(link_url=media_url, assume_is_video=False, needs_preview=True, get_playable_url=True) if ld: if not preview: preview = ld.poster if (addon.getSetting('include_albums') == 'true') and (ld.media_type == sitesBase.TYPE_ALBUM): dictlist = listAlbum(media_url, title, 'return_dictlist') for d in dictlist: t2 = d.get('li_label') if d.get('li_label') else title d['li_label'] = t2 entries.append(d) else: if addon.getSetting('use_reddit_preview') == 'true': if preview: image = preview elif ld.poster: image = ld.poster else: if ld.poster: image = ld.poster #entries.append([title,ld.poster,preview_w, preview_h,len(entries)]) elif preview: image = preview #entries.append([title,preview,preview_w, preview_h,len(entries)]) append_entry(entries, title, image, preview_w, preview_h, description) else: append_entry(entries, title, preview, preview_w, preview_h, description) except Exception as e: log(' autoPlay exception:' + str(e)) entries = remove_dict_duplicates(entries, 'DirectoryItem_url') for i, e in enumerate(entries): log(' possible playable items({0}) {1}...{2}x{3} {4}'.format( i, e['li_label'].ljust(15)[:15], repr(e.get('width')), repr(e.get('height')), e.get('DirectoryItem_url'))) if len(entries) == 0: log(' Play All: no playable items') xbmc.executebuiltin( 'XBMC.Notification("%s","%s")' % (translation(32054), translation(32055))) #Play All No playable items return log("**********playing slideshow*************") for e in entries: q.put(e) s = ScreensaverManager(ev, q) try: s.start_loop() except Exception as e: log(" EXCEPTION slideshowAlbum:=" + str(sys.exc_info()[0]) + " " + str(e)) return