Esempio 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
Esempio n. 2
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
Esempio n. 3
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
Esempio n. 4
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)
    results = tclient.dashboard(limit=20,
                                offset=offset,
                                type='video',
                                since_id=lastid)
    nextoff = int(20 + int(offset))
    nextitem = ListItem(label="Next Page -> #{0}".format(int(strpage) + 1),
                        label2="Liked Videos",
                        icon=__imgnext__,
                        thumbnail=__imgnext__,
                        path=plugin.url_for(dashboard,
                                            offset=nextoff,
                                            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', None) is not None:
            if results.get('posts', None):
                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])
    litems, alltags = dashboard_items(listlikes)
    item = listlikes[-1]
    nextid = item.get('id', )
    plugin.set_setting('lastid', nextid)
    if nextid >= lastid - 20:
        newid, nextid = get_postids(ForceUpdate=True)
        newoff = -1 * (newid - nextid)
        nextitem.path = plugin.url_for(dashboard, offset=newoff, lastid=newid)
        msgrefresh = "Current ID:{0} Starting Newest ID: {1} off: {2} Latest PostID: {3} new Offset: {4})".format(
            str(lastid), str(newid), str(nextid), str(offset), str(newoff))
        plugin.notify(msgrefresh)
    savetags(alltags)
    litems.append(nextitem)
    return litems
Esempio n. 5
0
    def test_art(self):
        item = ListItem()
        art = {'thumb': None, 'icon': None}
        self.assertEqual(item.art, art)

        art2 = {'thumb': 'something', 'icon': 'else'}
        item.art = art2
        self.assertEqual(item.art, art2)

        item.set_art(art)
        self.assertEqual(item.art, art)
Esempio n. 6
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
Esempio n. 7
0
def dashboard(offset=0):
    # setview_thumb()
    likes = {}
    listlikes = []
    litems = []
    alltags = []
    nextoff = int(60 + int(offset))
    strpage = str(nextoff / 60)
    pathnext = plugin.url_for(dashboard, offset=nextoff)
    nextitem = ListItem(label="[B]Page #{0}[/B] ->".format(
        str(int(strpage) + 1)),
                        label2=pathnext,
                        icon=__imgnext__,
                        thumbnail=__imgnext__,
                        path=pathnext)
    nextitem.set_art({
        'poster': __imgnext__,
        'thumbnail': __imgnext__,
        'fanart': __imgnext__
    })
    nextitem.is_folder = True
    litems = [nextitem]
    litems.append(dashboard_getitems(offset))
    return litems
Esempio n. 8
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
Esempio n. 9
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
Esempio n. 10
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
Esempio n. 11
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
Esempio n. 12
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
Esempio n. 13
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
Esempio n. 14
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