Ejemplo n.º 1
0
def blogs_following(offset=0):
    blogs = {}
    litems = []
    blogres = []
    listblogs = []
    litems = []
    name = ''
    updated = ''
    url = ''
    desc = ''
    strpage = str(((int(offset) + 20) / 20))
    nextitem = ListItem(label="Next Page -> #{0}".format(int(strpage) + 1),
                        label2="More",
                        icon=__imgnext__,
                        thumbnail=__imgnext__,
                        path=plugin.url_for(blogs_following,
                                            offset=int(20 + int(offset))))
    nextitem.set_art({
        'poster': __imgnext__,
        'thumbnail': __imgnext__,
        'fanart': __imgnext__
    })
    nextitem.is_folder = True
    litems = [nextitem]
    results = following_list(offset=offset,
                             max=20)  # max not working right now, max=50)
    for b in results:
        thumb = 'https://api.tumblr.com/v2/blog/{0}/avatar/64'.format(
            name)  #__imgtumblr__
        try:
            thumbd = {}
            name = b.get(u'name', '')
            title = b.get(u'title', '')
            desc = Strip(b.get(u'description', ''))
            url = b.get(u'url', "http://{0}.tumblr.com".format(name))
            updated = b.get(u'updated', 0)
            updatetext = datetime.datetime.fromtimestamp(
                updated)  #.isoformat()
            thumb = 'https://api.tumblr.com/v2/blog/{0}/avatar/64'.format(name)
            iurl = plugin.url_for(endpoint=blogposts, blogname=name, offset=0)
            lbl = "[COLOR yellow][B]{0}[/B][/COLOR] ({2}:{3} {4}/{5})\n[I]{1}[/I]".format(
                name, title.encode('latin-1', 'ignore'), updatetext.hour,
                updatetext.minute, updatetext.day, updatetext.month)
            lbl2 = title + "\n" + desc.encode('latin-1', 'ignore')
            litem = ListItem(label=lbl,
                             label2=lbl2,
                             icon=thumb,
                             thumbnail=thumb,
                             path=iurl)
            litem.set_art({
                'poster': thumb,
                'thumbnail': thumb,
                'fanart': thumb
            })
            litem.is_folder = True
            litem.playable = False
            litems.append(litem)
        except:
            pass
    return litems
Ejemplo n.º 2
0
def new_viditem(v={}, as_dict=False):
    pathdl = plugin.url_for(endpoint=download, vurl=v.get('contentUrl', v.get('hostPageUrl', '')))
    ctxlist = []
    citem = ('Download', 'RunPlugin({0})'.format(pathdl),)
    ctxlist.append(citem)
    pathdel = plugin.url_for(endpoint=fav_del, idvid=v.get('videoId', ''))
    citem = ('DELETE', 'RunPlugin({0})'.format(pathdel),)
    ctxlist.append(citem)
    img = v.get('thumbnail', v.get('thumbnailUrl', 'DefaultVideo.png'))
    lbl = v.get('label', v.get('name', ''))
    lbl2 = v.get('label2', v.get('videoId', ''))
    vidpath = v.get('path', None)
    if vidpath is None:
        vidpath = plugin.url_for(endpoint=play, vtitle=v.get('name', lbl), vurl=v.get('contentUrl', v.get('hostPageUrl', lbl2)))
    xitem = None
    if not as_dict:
        xitem = ListItem(label=lbl, label2=lbl2, icon=img, thumbnail=img, path=vidpath)
        xitem.add_context_menu_items(items=ctxlist, replace_items=False)
        xitem.playable = True
        xitem.is_folder = False
        xitem.set_info(info_type='video', info_labels={'Title': lbl, 'Plot': lbl2, 'Premiered': v.get('datePublished', '')})
        xitem.thumbnail = img
        xitem.icon = img
        idvid = v.get('videoId', 0)
        if idvid is not 0:
            xitem.set_property(key='videoId', value=idvid)
            xitem.set_info(info_type='video', info_labels={'VideoID': idvid})
    else:
        xitem = {'label': lbl, 'label2': lbl2, 'icon': img, 'thumbnail': img, 'is_playable': True, 'path': vidpath}
    return xitem
Ejemplo n.º 3
0
def resolveurl():
    playable = None
    resolved = ""
    url = plugin.keyboard(default='', heading='Video Page URL')
    if url is not None:
        name = url
        if len(url) > 0:
            url = url.encode('utf-8', 'ignore')
            item = ListItem(label=name,
                            label2=url,
                            icon='DefaultVideo.png',
                            thumbnail='DefaultVideo.png',
                            path=plugin.url_for(endpoint=play, url=url))
            item.playable = True
            item.set_info(info_type='video',
                          info_labels={
                              'Title': url,
                              'Plot': url
                          })
            item.add_stream_info(stream_type='video', stream_values={})
            playable = play(url)

            try:
                resolved = urlresolver.resolve(url)
            except:
                resolved = ""
            plugin.notify(msg=resolved, title="Playing..")
            return plugin.play_video(playable)
    #plugin.redirect(plugin.url_for(index))
    #plugin.clear_added_items()
    #plugin.end_of_directory()
    #return None
    return None
Ejemplo n.º 4
0
def makeitem(name=None, img=None, path='blogposts', playable=False, **kwargs):
    #if doDebug():
    xitem = None
    try:
        if not path.startswith('plugin://'):
            itempath = plugin.url_for(endpoint=path, items=kwargs)
        else:
            itempath = path
        lbl2 = kwargs.get("label2",
                          itempath.partition('plugin.video.tumblrv/')[-1])
        if img is None:
            img = "https://api.tumblr.com/v2/blog/{0}/avatar/64".format(name)
        xitem = ListItem(label=name,
                         label2=lbl2,
                         icon=img,
                         thumbnail=img,
                         path=itempath)
        xitem.playable = playable
        xitem.poster = img
        #litem = {'label': name, 'thumbnail': img, 'icon': img, 'is_playable': playable, 'path': itempath)}
        if path == 'blogposts':
            img = "https://api.tumblr.com/v2/blog/{0}/avatar/64".format(name)
        elif plugin.request.path.find(
                'following/') != -1 or plugin.request.path.find(
                    'liked/') != -1 or plugin.request.path.find(
                        'dashboard/') != -1:
            blogname = kwargs.get('blogname', name)
            ctxaction = "RunPlugin({0})".format(
                plugin.url_for(endpoint=blogposts, blogname=blogname))
            cname = "[COLOR green]GOTO:[/COLOR] {0}".format(blogname)
            citem = (
                cname,
                ctxaction,
            )
            ctxlist.append(citem)
            vidurl = kwargs.get("vidurl", None)
            if vidurl is not None:
                pathdl = plugin.url_for(endpoint=download, urlvideo=vidurl)
                citem = (
                    'Download',
                    'RunPlugin({0})'.format(pathdl),
                )
                ctxlist.append(citem)
            vidid = kwargs.get('id', None)
            if vidid is not None:
                pathaddlike = plugin.url_for(endpoint=addlike, id=vidid)
                citem = (
                    'Like',
                    'RunPlugin({0})'.format(pathaddlike),
                )
                ctxlist.append(citem)
        xitem.add_context_menu_items(items=ctxlist, replace_items=False)
    except Exception as ex:
        outmsg = "Error: {0}\n{1}\n{2}\n".format(str(ex), str(ex.message),
                                                 str(ex.args))
        plugin.notify(msg=outmsg, delay=10000)
        print outmsg
    return xitem
Ejemplo n.º 5
0
def dashboard_old(listlikes, alltags, litems):
    for item in listlikes:
        if item.get('type', '') == 'video':
            b = item
            img = item.get("thumbnail_url", __imgtumblr__)
            img2 = item.get("image_permalink", __imgtumblr__)
            alltags.extend(item.get('tags', []))
            try:
                if len(b.get('slug', '')) > 0:
                    lbl = b.get('slug', '')
                elif len(b.get('title', '')) > 0:
                    lbl = b.get('title', '')
                elif len(b.get('caption', '')) > 0:
                    lbl = Strip(b.get('caption', ''))
                elif len(b.get('summary', '')) > 0:
                    lbl = b.get('summary', '')
                elif len(b.get('source_title', '')) > 0:
                    lbl = b.get('source_title', '')
                else:
                    lbl = b.get('short_url', '')
                if len(item.get('summary', '')) > 0:
                    lbl2 = item.get('summary', '')
                else:
                    lbl2 = item.get('blog_name', '') + " / " + item.get('source_title', '') + "(" + item.get(
                        'slug_name', '') + ")"
            except:
                lbl = b.get('blog_name', '')
                lbl2 = b.get('short_url', '')
            vidurl = item.get('video_url', '')
            img = item.get('thumbnail_url',
                           item.get('image_permalink', item.get('image_permalink', __imgtumblr__))).replace('https:',
                                                                                                            'http:')
            img2 = item.get('image_permalink',
                            item.get('thumbnail_url', item.get('thumbnail_url', __imgtumblr__))).replace('https:',
                                                                                                         'http:')
            if vidurl is not None and len(vidurl) > 10:
                if len(b.get('caption', '')) > 0:
                    lbl = Strip(b.get('caption', ''))
                litem = ListItem(label=lbl, label2=lbl2, icon=img2, thumbnail=img, path=vidurl)
                litem.playable = True
                litem.is_folder = False
                if item.get('date', '') is not None:
                    rdate = str(item.get('date', '')).split(' ', 1)[0].strip()
                litem.set_info(info_type='video', info_labels={'Date': rdate})
                litem.set_art({'poster': img2, 'thumbnail': img, 'fanart': img2})
                pathdl = plugin.url_for(endpoint=download, urlvideo=vidurl)
                pathaddlike = plugin.url_for(endpoint=addlike, id=item.get('id', ''))
                litem.add_context_menu_items(
                    [('Download', 'RunPlugin({0})'.format(pathdl)), ('Like', 'RunPlugin({0})'.format(pathaddlike)),
                     ('Show Image', 'ShowPicture({0})'.format(img)), ])
                litems.append(litem)
    item = listlikes[-1]
    plugin.set_setting('lastid', str(item.get('id', lastid)))
    savetags(alltags)
    # litems.append(nextitem)
    return litems
Ejemplo n.º 6
0
def following(offset=0):
    blogs = {}
    litems = []
    blogres = []
    listblogs = []
    litems = []
    name = ''
    updated = ''
    url = ''
    desc = ''
    strpage = str(((int(offset) + 20) / 20))
    nextitem = ListItem(label="Next Page -> #{0}".format(int(strpage) + 1),
                        label2="More",
                        icon=__imgnext__,
                        thumbnail=__imgnext__,
                        path=plugin.url_for(following,
                                            offset=int(20 + int(offset))))
    nextitem.set_art({
        'poster': __imgnext__,
        'thumbnail': __imgnext__,
        'fanart': __imgnext__
    })
    nextitem.is_folder = True
    litems = [nextitem]
    results = following_list(
        offset=offset)  # max not working right now, max=50)
    for b in results:
        thumb = __imgtumblr__
        try:
            thumbd = {}
            name = b.get(u'name', '')
            title = b.get(u'title', '')
            desc = b.get(u'description', '')
            url = b.get(u'url', "http://{0}.tumblr.com".format(name))
            updated = b.get(u'updated', '')
            thumb = b.get('thumb', __imgtumblr__)
            iurl = plugin.url_for(endpoint=blogposts, blogname=name, offset=0)
            lbl = "{0}\n{1}".format(name, title.encode('latin-1', 'ignore'))
            lbl2 = desc.encode('latin-1', 'ignore')
            litem = ListItem(label=lbl,
                             label2=lbl2,
                             icon=thumb,
                             thumbnail=thumb,
                             path=iurl)
            litem.set_art({
                'poster': thumb,
                'thumbnail': thumb,
                'fanart': thumb
            })
            litem.is_folder = True
            litem.playable = False
            litems.append(litem)
        except:
            pass
    return litems
Ejemplo n.º 7
0
def play(title, video, url):
    resolved = None
    mediaurl = None
    vidhtml = urllib2.urlopen(url).read()
    vidurl = ''
    try:        
        matches = re.compile('(http://[^"<]+?.mp4[^"<]+?)"', re.I + re.M + re.S + re.U).findall(vidhtml)[0]
        if matches is not None:
            vidurl = matches
            xbmc.log("MATCH MP4 = {0}".format(vidurl))            
            vli = ListItem(label=title, label2=url, icon=video, thumbnail=video, path=vidurl)
            vli.playable = True
            #plugin.set_resolved_url(plugin.url_for(play, title=title, video=video, url=url))
            #xbmc.Player().play(vidurl)
            #plugin.play_video(vli)
            #return plugin.play_video(vli)                        
            #return xbmc.Player().play(vidurl)
    except:
        pass
    try:
        if vidurl == '':
            matches2 = re.compile('(http://[^"<]+?.flv[^"<]+?)"', re.I + re.M + re.S + re.U).findall(vidhtml)[0]            
            if matches2 is not None:
                vidurl = matches2
                xbmc.log("MATCH MP4 = {0}".format(vidurl))            
                vli = ListItem(label=title, label2=url, icon=video, thumbnail=video, path=vidurl)
                vli.playable = True
                #plugin.set_resolved_url(plugin.url_for(play, title=title, video=video, url=url))
                #xbmc.Player().play(vidurl)
                #plugin.set_resolved_url(vli)
                #plugin.play_video(vli)
                #plugin.set_resolved_url(plugin.url_for(play, title=title, video=video, url=url))
            #return plugin.play_video(vli)
    except:
        pass
    #plugin.set_resolved_url(plugin.url_for(play, title=title, video=video, url=url))
    try:
        if vli is not None:
            plugin.set_resolved_url(vli)
            return plugin.play_video(vli)
    except:
        pass
Ejemplo n.º 8
0
def dashboard_items(results=[]):
    alltags = []
    litems = []
    for item in results:
        if item.get('type', '') == 'video':
            b = {}
            b.update(item)
            lbl = ""
            lbl2 = ""
            img = item.get('thumbnail_url',
                           item.get('image_permalink', __imgtumblr__))
            alltags.extend(item.get('tags', []))
            try:
                if len(b.get('slug', '')) > 0:
                    lbl = b.get('slug', '')
                elif len(b.get('title', '')) > 0:
                    lbl = b.get('title', '')
                elif len(b.get('caption', '')) > 0:
                    lbl = Strip(b.get('caption', ''))
                elif len(b.get('summary', '')) > 0:
                    lbl = b.get('summary', '')
                elif len(b.get('source_title', '')) > 0:
                    lbl = b.get('source_title', '')
                else:
                    lbl = b.get('short_url', '')
                if len(item.get('summary', '')) > 0:
                    lbl2 = item.get('summary', '')
                else:
                    lbl2 = item.get('blog_name', "") + " / " + item.get(
                        'source_title', '') + "(" + item.get('slug_name',
                                                             '') + ")"
            except:
                lbl = b.get(b.keys()[0], "")
                lbl2 = b.get(b.keys()[-1], "")
            vidurl = item.get('video_url', "")
            if vidurl is not None and len(vidurl) > 10:
                litem = ListItem(label=lbl,
                                 label2=lbl2,
                                 icon=img,
                                 thumbnail=img,
                                 path=vidurl)
                litem.playable = True
                litem.is_folder = False
                if item.get('date', '') is not None:
                    rdate = str(item.get('date', '')).split(' ', 1)[0].strip()
                litem.set_info(info_type='video', info_labels={'Date': rdate})
                litem.set_art({'poster': img, 'thumbnail': img, 'fanart': img})
                pathdl = plugin.url_for(endpoint=download, urlvideo=vidurl)
                litem.add_context_menu_items([
                    ('Download', 'RunPlugin({0})'.format(pathdl)),
                ])
                litems.append(litem)
    return litems, alltags
Ejemplo n.º 9
0
def play(title, video, url):
    """
    Play attempts to scrape the video's page and find the actual video file to play. This is still buggy but seems to work on
    a lot of the sites but not all the time so any help on this function working better would be appreciated. I pass in the
    title of the movie and the video tags the Thumbnail which I use to create a proper ListItem with the scrapped MP4 url
    :param title: Video Title to play passed to XBMC in a new ListItem object with resolved URL of video scraped from url
    :param video: Thumbnail URL of the video used as the icon and thumbnail for ListItem to play
    :param url: URL of the embed/video page to scrape for the real playable video file
    :return: ListItem of video with path = scraped url of the MP4/Video file hopefully
    """
    resolved = None
    mediaurl = None
    vidhtml = urllib2.urlopen(url).read()
    vidurl = ''
    vli = None
    try:
        matches = re.compile('(http://[^"<]+?.mp4[^"<]+?)"', re.I + re.M + re.S + re.U).findall(vidhtml)[0]
        if matches is not None:
            vidurl = matches
            xbmc.log("MATCH MP4 = {0}".format(vidurl))
            vli = ListItem(label=title, label2=url, icon=video, thumbnail=video, path=vidurl)
            vli.playable = True
        else:
            matches = re.compile('(http://[^"<]+?.flv[^"<]+?)"', re.I + re.M + re.S + re.U).findall(vidhtml)[0]
            if matches is not None:
                vidurl = matches
                xbmc.log("MATCH FLV = {0}".format(vidurl))
                vli = ListItem(label=title, label2=url, icon=video, thumbnail=video, path=vidurl)
                vli.playable = True
    except:
        pass
    try:
        if vli is not None:
            plugin.set_resolved_url(vli)
            plugin.play_video(vli)
            # return plugin.play_video(vli)
    except:
        pass
Ejemplo n.º 10
0
def resolveurl():
    if plugin.get_setting('debugon', converter=bool): web_pdb.set_trace()

    url = plugin.keyboard(default='', heading='Video Page URL')
    if url is not None:
        name = url
        if len(url) > 0:
            item = ListItem(label=name, label2=url, icon='DefaultVideo.png', thumbnail='DefaultVideo.png',
                            path=plugin.url_for(endpoint=play, url=url))
            item.playable = True
            item.set_info(type='video', info_labels={'Title': url, 'Plot': url})
            item.add_stream_info(stream_type='video', stream_values={})
            playable = play(url)
            plugin.notify(msg=playable.path, title="Playing..")
            plugin.play_video(playable)
    plugin.clear_added_items()
    plugin.end_of_directory()
Ejemplo n.º 11
0
def oldplay(title, video, url):
    try:
        if vidurl is None:
            m1 = re.compile('href="(https?.+mp4[^"]*)".', re.I + re.M + re.S + re.U).findall(vidhtml)
            m2 = re.compile('flv_url=(http[^"]+?)&amp;', re.I+re.M).findall(vidhtml)
            m3 = re.compile("videoUrl: '([^']+)", re.I+re.M).findall(vidhtml)
            m4 = re.compile("480: '([^']+)", re.I+re.M).findall(vidhtml)
            m5 = re.compile('source src="([^"]+)"', re.I+re.M).findall(vidhtml)
            m6 = re.compile("var player_quality_480p = '([^\"]+.mp4[^']*)';", re.I+re.M).findall(vidhtml)
            if m1 is not None:
                vidurl = m1.pop()
                xbmc.log("MATCH 1 = {0}".format(vidurl))
            if m2 is not None:
                vidurl = m2.pop()
                xbmc.log("MATCH 2 = {0}".format(vidurl))
            if m3 is not None:
                vidurl = m3.pop()
                xbmc.log("MATCH 3 = {0}".format(vidurl))                    
            if m4 is not None:
                vidurl = m4.pop()
                xbmc.log("MATCH 4 = {0}".format(vidurl))                    
            if m5 is not None:
                vidurl = m5.pop()
                xbmc.log("MATCH 5 = {0}".format(vidurl))
            if m6 is not None:
                vidurl = m6.pop()
                xbmc.log("MATCH 6 = {0}".format(vidurl))
            #matches = re.compile("videoUrl: '([^']*)',", re.I + re.M + re.S + re.U).findall(vidhtml)[0]
            #vidurl = matches
            #vidurl = matches.split(' ', 1)[0].strip('"')
            #xbmc.Player().play(vidurl)
            if vidurl is not None:
                xbmc.log("PLAY matches vidpage: \n{0}".format(vidurl))
                vli = ListItem(label=title, label2=url, icon=video, thumbnail=video, path=vidurl)
                vli.playable = True
                plugin.set_resolved_url(vli)
                plugin.play_video(vli)
                # return plugin.play_video(vli)
            else:
                xbmc.log("FAILED to resolve url to movie file. {0}".format(url))
    except:
        xbmc.log("failed to resolve url to movie file.")
Ejemplo n.º 12
0
def dashboard(lastid=0, offset=0):
    #setview_thumb()
    likes = {}
    listlikes = []
    litems = []
    strpage = str(((int(offset) + 20) / 20))
    # results = tclient.dashboard(offset=offset, limit=100)
    lastid = plugin.get_setting('lastid', int)
    if lastid == 0:
        lastid = 10000000000
    if lastid is None or lastid < 1000000:
        lastid = 10000000000
    results = tclient.dashboard(limit=20,
                                offset=offset,
                                type='video',
                                since_id=lastid)
    nextitem = ListItem(label="Next Page -> #{0}".format(int(strpage) + 1),
                        label2="Liked Videos",
                        icon=__imgnext__,
                        thumbnail=__imgnext__,
                        path=plugin.url_for(dashboard,
                                            offset=int(20 + int(offset)),
                                            lastid=lastid))
    nextitem.set_art({
        'poster': __imgnext__,
        'thumbnail': __imgnext__,
        'fanart': __imgnext__
    })
    nextitem.is_folder = True
    # litems = [nextitem]
    litems = []
    alltags = []
    if results is not None:
        if results.get('posts', '') is not None:
            if results.get('posts', ''):
                results = results.get('posts', '')
            try:
                if isinstance(results, list):
                    listlikes = results
                else:
                    listlikes = results.get(results.keys()[0])
            except:
                listlikes = []
        else:
            listlikes = results.get(results.keys()[-1])
    for item in listlikes:
        if item.get('type', '') == 'video':
            b = item
            img = __imgtumblr__
            alltags.extend(item.get('tags', []))
            if 'thumb' in str(item.keys()[:]):
                if item.get('thumbnail_url', '') is not None:
                    img = item.get(
                        'thumbnail_url', ''
                    )  # .replace('https', 'http') #item.get('thumbnail_url','')
            elif 'image' in str(item.keys()[:]):
                if item.get('image_permalink', ""):
                    img = item.get('image_permalink', "")
            try:
                if len(b.get('slug', '')) > 0:
                    lbl = b.get('slug', '')
                elif len(b.get('title', '')) > 0:
                    lbl = b.get('title', '')
                elif len(b.get('caption', '')) > 0:
                    lbl = Strip(b.get('caption', ''))
                elif len(b.get('summary', '')) > 0:
                    lbl = b.get('summary', '')
                elif len(b.get('source_title', '')) > 0:
                    lbl = b.get('source_title', '')
                else:
                    lbl = b.get('short_url', '')
                if len(item.get('summary', '')) > 0:
                    lbl2 = item.get('summary', '')
                else:
                    lbl2 = item.get('blog_name', '') + " / " + item.get(
                        'source_title', '') + "(" + item.get('slug_name',
                                                             '') + ")"
            except:
                lbl = b.get('blog_name', '')
                lbl2 = b.get('short_url', '')
            img = item.get('thumbnail_url', '')
            vidurl = item.get('video_url', '')
            if vidurl is not None and len(vidurl) > 10:
                if len(b.get('caption', '')) > 0:
                    lbl = Strip(b.get('caption', ''))
                litem = ListItem(label=lbl,
                                 label2=lbl2,
                                 icon=img,
                                 thumbnail=img,
                                 path=vidurl)
                litem.playable = True
                litem.is_folder = False
                if item.get('date', '') is not None:
                    rdate = str(item.get('date', '')).split(' ', 1)[0].strip()
                litem.set_info(info_type='video', info_labels={'Date': rdate})
                litem.set_art({'poster': img, 'thumbnail': img, 'fanart': img})
                pathdl = plugin.url_for(endpoint=download, urlvideo=vidurl)
                pathaddlike = plugin.url_for(endpoint=addlike,
                                             id=item.get('id', ''))
                litem.add_context_menu_items([
                    ('Download', 'RunPlugin({0})'.format(pathdl)),
                    ('Like', 'RunPlugin({0})'.format(pathaddlike)),
                ])
                litems.append(litem)
    item = listlikes[-1]
    plugin.set_setting('lastid', str(item.get('id', lastid)))
    savetags(alltags)
    litems.append(nextitem)
    return litems
Ejemplo n.º 13
0
def search():
    # plugin.log.debug(TUMBLRAUTH)
    # client = TumblrRestClient(**TUMBLRAUTH)
    # info = client.info()
    litems = []
    searchtxt = ''
    searchquery = ''
    offsetnum = 0
    searchtxt = plugin.get_setting('lastsearch')
    searchtxt = plugin.keyboard(searchtxt, 'Search All Sites', False)
    searchquery = searchtxt.replace(' ', '+')
    plugin.set_setting(key='lastsearch', val=searchtxt)
    results = following_list(offset=offsetnum)
    listmatch = []
    max = 20
    # if len(results) < 20:
    #    max = len(results) - 1
    for blog in results:
        name = blog.get('name', '')
        posts = tclient.posts(name, type='video')
        for post in posts.get('posts', []):
            for k, v in post.items():
                try:
                    if searchquery.lower() in str(v.encode('latin-1', 'ignore')).lower():
                        listmatch.append(post)
                        break
                except:
                    pass
    plugin.notify(msg="Matches: {0}".format(str(len(listmatch))))
    alltags = []
    for post in listmatch:
        lbl2 = post.get('blog_name', '')
        lbl = post.get('slug', '').replace('-', ' ')
        img = post.get('thumbnail_url', post.get('image_permalink', __imgtumblr__))
        img2 = post.get('image_permalink', post.get('thumbnail_url', __imgtumblr__))
        alltags.extend(post.get('tags', []))
        try:
            if post.get('slug', '') is not None:
                lbl = post.get('slug', '').replace('-', ' ')
            if len(post.get('caption', '')) > 0:
                lbl = Strip(post.get('caption', ''))
            elif len(post.get('summary', '')) > 0:
                lbl = post.get('summary', '')
            elif len(post.get('source_title', '')) > 0:
                lbl = post.get('source_title', '')
            else:
                lbl = post.get('short_url', '')
            if post.get('video_url', '') is not None:
                vidurl = post.get('video_url', '')
        except:
            plugin.notify(str(repr(post)))
        litem = ListItem(label=lbl, label2=lbl2, icon=img2, thumbnail=img, path=vidurl)
        litem.playable = True
        litem.is_folder = False
        if len(post.get('date', '')) > 0:
            rdate = str(post.get('date', '')).split(' ', 1)[0].strip()
        litem.set_info(info_type='video', info_labels={'Date': rdate, 'Duration': post.get('duration', '')})
        litem.set_art({'poster': img2, 'thumbnail': img, 'fanart': img2})
        pathdl = plugin.url_for(endpoint=download, urlvideo=vidurl)
        pathaddlike = plugin.url_for(endpoint=addlike, id=post.get('id', ''))
        litem.add_context_menu_items(
            [('Download', 'RunPlugin({0})'.format(pathdl)), ('Like', 'RunPlugin({0})'.format(pathaddlike)), ])
        litems.append(litem)
    savetags(alltags)
    return litems
Ejemplo n.º 14
0
def blogposts(blogname, offset=0):
    listposts = []
    lbl = ''
    lbl2 = ''
    vidurl = ''
    results = []
    alltags = []
    litems = []
    if blogname.find('.') != -1:
        shortname = blogname.split('.', 1)[-1]
        if shortname.find('.') != -1:
            blogname = shortname.lsplit('.')[0]
    strpage = str((20 + int(offset)) / 20)
    nextitem = ListItem(label="Next Page -> #{0}".format(strpage), label2=blogname, icon=__imgnext__,
                        thumbnail=__imgnext__,
                        path=plugin.url_for(blogposts, blogname=blogname, offset=int(20 + int(offset))))
    nextitem.set_art({'poster': __imgnext__, 'thumbnail': __imgnext__, 'fanart': __imgnext__})
    nextitem.is_folder = True
    # litems = [nextitem]
    results = tclient.posts(blogname=blogname, limit=20, offset=int(offset), type='video')
    if results is not None:
        if len(results.get('posts', '')) > 1:
            results = results.get('posts', '')
        for post in results:
            lbl2 = post.get('blog_name', '')
            lbl = post.get('slug', '').replace('-', ' ')
            img = post.get('thumbnail_url', post.get('image_permalink', __imgtumblr__))
            img2 = post.get('image_permalink', post.get('thumbnail_url', __imgtumblr__))
            alltags.extend(post.get('tags', []))
            try:
                if post.get('slug', '') is not None:
                    lbl = post.get('slug', '').replace('-', ' ')
                if len(post.get('caption', '')) > 0:
                    lbl = Strip(post.get('caption', ''))
                elif len(post.get('summary', '')) > 0:
                    lbl = post.get('summary', '')
                elif len(post.get('source_title', '')) > 0:
                    lbl = post.get('source_title', '')
                else:
                    lbl = post.get('short_url', '')
                if post.get('video_url', '') is not None:
                    vidurl = post.get('video_url', '')
            except:
                plugin.notify(str(repr(post)))
            litem = ListItem(label=lbl, label2=lbl2, icon=img2, thumbnail=img, path=vidurl)
            litem.playable = True
            litem.is_folder = False
            if len(post.get('date', '')) > 0:
                rdate = str(post.get('date', '')).split(' ', 1)[0].strip()
            litem.set_info(info_type='video', info_labels={'Date': rdate, 'Duration': post.get('duration', '')})
            litem.set_art({'poster': img2, 'thumbnail': img, 'fanart': img2})
            pathdl = plugin.url_for(endpoint=download, urlvideo=vidurl)
            pathaddlike = plugin.url_for(endpoint=addlike, id=post.get('id', ''))
            litem.add_context_menu_items(
                [('Download', 'RunPlugin({0})'.format(pathdl)), ('Like', 'RunPlugin({0})'.format(pathaddlike)), ])
            litems.append(litem)
    else:
        litems = []
        backurl = ''
        if offset == 0:
            backurl = plugin.url_for(endpoint=blogs_following, offset=0)
        else:
            backurl = plugin.url_for(blogposts, blogname=blogname, offset=(int(offset) - 20))
        nextitem = ListItem(label="No Results - GO BACK".format(strpage), label2=blogname, icon=__imgtumblr__,
                            thumbnail=__imgtumblr__, path=backurl)
        nextitem.set_art({'poster': __imgtumblr__, 'thumbnail': __imgtumblr__, 'fanart': __imgtumblr__})
        nextitem.is_folder = True
        litems = [nextitem]
    savetags(alltags)
    litems.append(nextitem)
    return litems
Ejemplo n.º 15
0
def tags(tagname='', timestamp=0):
    atags = {}
    taglist = []
    litems = []
    if tagname == '0':
        tagname = plugin.keyboard(plugin.get_setting('lastsearch'), 'Search for tags')
        plugin.set_setting('lastsearch', tagname)
    nextstamp = time.mktime((datetime.datetime.fromtimestamp(float(timestamp)) - weekdelta).timetuple())
    nstamp = str(nextstamp).split('.', 1)[0]
    nextitem = ListItem(label="Next -> {0}".format(time.ctime(nextstamp)), label2="Tagged Videos", icon=__imgnext__,
                        thumbnail=__imgnext__, path=plugin.url_for(tags, tagname=tagname, timestamp=nstamp))
    nextitem.set_art({'poster': __imgnext__, 'thumbnail': __imgnext__, 'fanart': __imgnext__})
    nextitem.is_folder = True
    # litems = [nextitem]
    if tagname is not None and len(tagname) > 0:
        results = tclient.tagged(tagname, filter='text')  # ), before=float(timestamp))
        if results is not None:
            for res in results:
                if res.get('type', '') == 'video': taglist.append(res)
        for item in taglist:
            b = {}
            b.update(item)
            lbl = ""
            lbl2 = ""
            img = __imgtumblr__
            if 'thumb' in str(item.keys()[:]):
                if item.get('thumbnail_url', '') is not None:
                    img = item.get('thumbnail_url', '')  # .replace('https', 'http') #item.get('thumbnail_url','')
            elif 'image' in str(item.keys()[:]):
                if item.get('image_permalink', ""):
                    img = item.get('image_permalink', "")
            try:
                plugin.log.debug(msg=item.get('thumbnail_url', ''))
                if len(b.get('slug', '')) > 0:
                    lbl = b.get('slug', '')
                elif len(b.get('title', '')) > 0:
                    lbl = b.get('title', '')
                elif len(b.get('caption', '')) > 0:
                    lbl = Strip(b.get('caption', ''))
                elif len(b.get('summary', '')) > 0:
                    lbl = b.get('summary', '')
                elif len(b.get('source_title', '')) > 0:
                    lbl = b.get('source_title', '')
                else:
                    lbl = b.get('short_url', '')
                if len(item.get('summary', '')) > 0:
                    lbl2 = item.get('summary', '')
                else:
                    lbl2 = item.get('blog_name', "") + " / " + item.get('source_title', '') + "(" + item.get(
                        'slug_name', '') + ")"
            except:
                lbl = b.get(b.keys()[0], "")
                lbl2 = b.get(b.keys()[-1], "")
            vidurl = item.get('video_url', "")
            if vidurl is not None and len(vidurl) > 10:
                litem = ListItem(label=lbl, label2=lbl2, icon=img, thumbnail=img, path=vidurl)
                litem.playable = True
                litem.is_folder = False
                if item.get('date', '') is not None:
                    rdate = str(item.get('date', '')).split(' ', 1)[0].strip()
                litem.set_info(info_type='video', info_labels={'Date': rdate})
                litem.set_art({'poster': img, 'thumbnail': img, 'fanart': img})
                litems.append(litem)
    litems = [nextitem]
    return litems
Ejemplo n.º 16
0
def liked(offset=0):
    # setview_thumb()
    likes = {}
    alltags = []
    litems = []
    listlikes = []
    strpage = str(((int(offset) + 20) / 20))
    nextitem = ListItem(label="Next Page -> #{0}".format(int(strpage) + 1), label2="Liked Videos", icon=__imgnext__,
                        thumbnail=__imgnext__, path=plugin.url_for(liked, offset=int(20 + int(offset))))
    nextitem.set_art({'poster': __imgnext__, 'thumbnail': __imgnext__, 'fanart': __imgnext__})
    nextitem.is_folder = True
    # litems = [nextitem]
    results = tclient.likes(limit=20, offset=int(offset))
    if results is not None:
        if results.get('liked_posts', '') is not None:
            listlikes = results.get('liked_posts', '')
        else:
            listlikes = results.get(results.keys()[-1])
    for item in listlikes:
        if item.get('type', '') == 'video':
            b = {}
            b.update(item)
            lbl = ""
            lbl2 = ""
            img = item.get('thumbnail_url', item.get('image_permalink', item.get('image_permalink', "")))
            alltags.extend(item.get('tags', []))
            if img == '':
                img = __imgtumblr__
            try:
                if len(b.get('slug', '')) > 0:
                    lbl = b.get('slug', '')
                elif len(b.get('title', '')) > 0:
                    lbl = b.get('title', '')
                elif len(b.get('caption', '')) > 0:
                    lbl = Strip(b.get('caption', ''))
                elif len(b.get('summary', '')) > 0:
                    lbl = b.get('summary', '')
                elif len(b.get('source_title', '')) > 0:
                    lbl = b.get('source_title', '')
                else:
                    lbl = b.get('short_url', '')
                if len(item.get('summary', '')) > 0:
                    lbl2 = item.get('summary', '')
                else:
                    lbl2 = item.get('blog_name', "") + " / " + item.get('source_title', '') + "(" + item.get(
                        'slug_name', '') + ")"
            except:
                lbl = b.get(b.keys()[0], "")
                lbl2 = b.get(b.keys()[-1], "")
            vidurl = item.get('video_url', "")
            if vidurl is not None and len(vidurl) > 10:
                litem = ListItem(label=lbl, label2=lbl2, icon=img, thumbnail=img, path=vidurl)
                litem.playable = True
                litem.is_folder = False
                if item.get('date', '') is not None:
                    rdate = str(item.get('date', '')).split(' ', 1)[0].strip()
                litem.set_info(info_type='video', info_labels={'Date': rdate})
                litem.set_art({'poster': img, 'thumbnail': img, 'fanart': img})
                pathdl = plugin.url_for(endpoint=download, urlvideo=vidurl)
                litem.add_context_menu_items([('Download', 'RunPlugin({0})'.format(pathdl)), ])
                litems.append(litem)
    savetags(alltags)
    litems.append(nextitem)
    return litems
Ejemplo n.º 17
0
def dashboard_items(results=[]):
    alltags = []
    litems = []
    for item in results:
        b = {}
        b.update(item)
        vidid = b.get('id', 0)
        ctxlist = []
        lbl = ""
        lbl2 = ""
        vidurl = item.get('video_url', '')
        if vidid != 0:
            pathaddlike = plugin.url_for(endpoint=addlike, id=vidid)
            citemlike = (
                'Like',
                'RunPlugin({0})'.format(pathaddlike),
            )
            ctxlist.append(citemlike)
        pathtoblog = plugin.url_for(blogposts,
                                    blogname=b.get('blog_name', ''),
                                    offset=0)
        citemblog = (
            'View Blog',
            'RunPlugin({0})'.format(pathtoblog),
        )
        ctxlist.append(citemblog)
        pathdl = plugin.url_for(endpoint=download, urlvideo=vidurl)
        citemdl = (
            'Download',
            'RunPlugin({0})'.format(pathdl),
        )
        ctxlist.append(citemdl)
        img = item.get('thumbnail_url',
                       item.get('image_permalink', __imgtumblr__))
        alltags.extend(item.get('tags', []))
        lbl = b.get(
            'summary',
            b.get(
                'source_title',
                b.get(
                    'short_url',
                    b.get(
                        'title',
                        b.get('blog_name',
                              b.get('source_title', b.get('caption', '')))))))
        lbl2 = b.get('blog_name', '') + " " + str(vidid) + " " + b.get(
            'short_url', '')
        from urllib import quote_plus
        if vidurl.find('.mp4') == -1 and len(vidurl) > 0:
            vidurl = "plugin://plugin.video.hubgay/playtumblr/" + quote_plus(
                vidurl)
        else:
            vidurl = "plugin://plugin.video.hubgay/playmovie/" + quote_plus(
                b.get('short_url', b.get('source_url', '')))
        litem = ListItem(label=lbl,
                         label2=lbl2,
                         icon=img,
                         thumbnail=img,
                         path=vidurl)
        litem.playable = True
        litem.is_folder = False
        postdate = item.get(
            'date',
            datetime.datetime.fromtimestamp(item.get(
                'timestamp', None)).isoformat(sep=' ').rpartition(':')[0])
        if postdate is not None:
            lbl2 += postdate
        else:
            postdate = datetime.datetime.fromtimestamp(
                item.get('timestamp',
                         1500000000)).isoformat(sep=' ').rpartition(':')[0]
        postdate = postdate.split(' ', 1)[0]
        litem.set_info(info_type='video', info_labels={'Date': postdate})
        litem.set_art({'poster': img, 'thumbnail': img, 'fanart': img})
        litem.add_context_menu_items(ctxlist)
        litems.append(litem)
    return litems, alltags
Ejemplo n.º 18
0
def following(offset=0):
    blogs = {}
    litems = []
    blogres = []
    listblogs = []
    litems = []
    name = ''
    updated = ''
    url = ''
    desc = ''
    strpage = str(((int(offset) + 50) / 50))
    nextitem = ListItem(label="Next Page -> #{0}".format(int(strpage) + 1),
                        label2="More",
                        icon=__imgnext__,
                        thumbnail=__imgnext__,
                        path=plugin.url_for(following,
                                            offset=int(50 + int(offset))))
    nextitem.set_art({
        'poster': __imgnext__,
        'thumbnail': __imgnext__,
        'fanart': __imgnext__
    })
    nextitem.is_folder = True
    #litems = [nextitem]
    results = following_list(
        offset=offset)  # max not working right now, max=50)
    for b in results:
        thumb = __imgtumblr__
        try:
            thumbd = {}
            name = b.get('name', '')
            title = b.get('title', '')
            desc = b.get('description', '')
            url = b.get('url', "http://{0}.tumblr.com".format(name))
            updated = b.get('updated', '')
            thumbd = tclient.avatar(name, 128)
            if len(thumbd.keys()) > 0:
                thumb = thumbd[thumbd.keys()[0]]
            if len(thumb) < 1:
                if len(b.get('theme', '{}')) > 0:
                    theme = b.get('theme', '{}')
                    if len(theme.get('header_image_scaled', '')) > 0:
                        thumb = theme.get('header_image_scaled', '')
            iurl = plugin.url_for(endpoint=blogposts, blogname=name, offset=0)
            lbl = "{0}\n{1}".format(name, title.encode('latin-1', 'ignore'))
            lbl2 = desc.encode('latin-1', 'ignore')
            litem = ListItem(label=lbl,
                             label2=lbl2,
                             icon=thumb,
                             thumbnail=thumb,
                             path=iurl)
            litem.set_art({
                'poster': thumb,
                'thumbnail': thumb,
                'fanart': thumb
            })
            litem.is_folder = True
            litem.playable = False
            litems.append(litem)
        except:
            pass
    #items = sorted(litems, key=lambda litems: litems.label2)
    # litems.append(nextitem) NO NEXT PAGE TODO: Make max work and paginate results as this is slow
    return litems