def searchMain():

    dirlst = [
        {
            'name': kodi.giveColor('Search All Providers', 'white'), 'url': 'all', 'mode': '1', 'icon': search_icon,
            'fanart': kodi.addonfanart, 'folder': True
        }
    ]

    sources = __all__
    search_sources = []
    for i in sources:
        try:
            if eval(i + ".search_tag") == 1: search_sources.append(i)
        except:
            pass

    if search_sources:
        for i in sorted(search_sources):
            dirlst.append(
                {
                    'name': kodi.giveColor('Search ' + i.title(), 'white'), 'url': i, 'mode': '1',
                    'icon': specific_icon % i, 'fanart': specific_fanart % i, 'folder': True
                }
            )

    buildDirectory(dirlst)
def githubSelect(name):
    from packlib import githubissues

    githubissues.run('tvaddonsco/plugin.video.adultflix', '%s' % name)
    file = xbmc.translatePath(
        os.path.join(kodi.datafolder,
                     '%s-issues-%s.csv' % (kodi.get_id(), name)))

    global msg_text

    with open(file, mode='r') as f:
        txt = f.read()
    items = re.findall('<item>(.+?)</item>', txt, re.DOTALL)
    if len(items) < 1:
        msg_text = kodi.giveColor(
            'No %s issues with AdultFlix at this time.' % name.title(),
            'deeppink', True)
    else:
        msg_text = kodi.giveColor(
            '%s Issues with AdultFlix\n' % name.title(), 'deeppink', True
        ) + kodi.giveColor(
            'Report Issues @ https://github.com/tvaddonsco/plugin.video.adultflix/issues',
            'white', True) + '\n---------------------------------\n\n'
        for item in items:
            try:
                id = re.findall('<id>([^<]+)', item)[0]
            except:
                id = 'Unknown'
            try:
                user = re.findall('<username>([^<]+)', item)[0]
            except:
                user = '******'
            try:
                label = re.findall('<label>([^<]+)', item)[0]
            except:
                label = 'Unknown'
            try:
                title = re.findall('<title>([^<]+)', item)[0]
            except:
                title = 'Unknown'
            try:
                body = re.findall('<body>([^<]+)', item)[0]
            except:
                body = 'Unknown'
            try:
                created = re.findall('<created>([^<]+)', item)[0]
                date, time = created.split('T')
            except:
                date = 'Unknown'
                time = 'Unknwon'
            msg_text += '[B]ID: %s | Label: %s \nBy: %s on %s at %s[/B] \n\nTitle: %s \nMessage %s \n\n---------------------------------\n\n' \
                        % (id,
                           kodi.githubLabel(label),
                           user,
                           date,
                           time.replace('Z', ''),
                           title,
                           body)
示例#3
0
def getHistory():
    history_on_off = kodi.get_setting("history_setting")

    if history_on_off == "true":

        lst = [
            ('Clear History', None, 21, history_icon, False)
            ,
            ('Disable History', None, 22, history_icon, False)
            ,
            ('-------------------------------------', None, 999, history_icon, False)
        ]

        conn = sqlite3.connect(historydb)
        conn.text_factory = str
        c = conn.cursor()
        c.execute("SELECT * FROM history ORDER BY ID DESC")

        for (ID, date, time, title, url, site, iconimage) in c.fetchall():
            try:
                if site == 'Local File':
                    lst += [('[%s | %s - %s] - %s' % (kodi.giveColor(site, 'pink'), date, time, title), url + 'site=' + site + 'typeid=history', 801, iconimage, False)]
                else:
                    lst += [('[%s | %s - %s] - %s' % (kodi.giveColor(site, 'pink'), date, time, title), url + 'site=' + site + 'typeid=history', 801, iconimage, True)]
            except:
                pass
        conn.close()

        if len(lst) < 4:
            lst += [('No History Found', None, 999, history_icon, False)]
    else:
        lst = [
            ('Enable History Monitoring', None, 22, history_icon, False)
            ,
            ('-------------------------------------', None, 22, history_icon, False)
            ,
            ('History monitoring is currently disabled.', None, 22, history_icon, False)
        ]

    dirlst = []
    for i in lst:
        if not i[3]:
            icon = kodi.addonicon
        else:
            icon = i[3]
        fanart = kodi.addonfanart
        dirlst.append(
            {
                'name': kodi.giveColor(i[0], 'white'), 'url': i[1], 'mode': i[2], 'icon': icon, 'fanart': fanart,
                'folder': False, 'isDownloadable': i[4]
            }
        )

    buildDirectory(dirlst)
def getFavorites():
    dirlist = []
    lst = [('Clear Favourites', None, 38, fav_icon, None, None, False, False),
           ('----------------------------------', None, 999, fav_icon, None,
            None, False, False)]
    conn = sqlite3.connect(favoritesdb)
    conn.text_factory = str
    c = conn.cursor()
    c.execute("SELECT * FROM favorites ORDER BY name ASC")
    for (name, url, mode, iconimage, _folder) in c.fetchall():
        try:
            site = url.split('|SPLIT|')[1]
        except:
            site = None
        if site: name = '[%s Video] %s' % (site, name)
        if _folder:
            name = '[%s] %s' % ('Directory', name)
        else:
            _folder = False
        lst += [(name, url, mode, iconimage, None, 'del', _folder, True)]
    conn.close()

    for i in lst:
        if not i[3]:
            icon = kodi.addonicon
        else:
            icon = i[3]
        if not i[4]:
            fanart = kodi.addonfanart
        else:
            fanart = i[4]
        dirlist.append({
            'name': kodi.giveColor(i[0], 'white'),
            'url': i[1],
            'mode': i[2],
            'icon': icon,
            'fanart': fanart,
            'fav': i[5],
            'folder': i[6],
            'isDownloadable': i[7]
        })

    if len(lst) < 3:
        dirlist.append({
            'name': kodi.giveColor('No Favorites Found', 'white'),
            'url': 'None',
            'mode': 999,
            'icon': fav_icon,
            'fanart': fanart,
            'folder': False
        })

    buildDirectory(dirlist)
def virtualReality():
    sources = __all__
    vr_sources = []
    base_name = []
    menu_mode = []
    art_dir = []
    sources = [i for i in sources]
    for i in sources:
        try:
            if eval(i + ".type") == 'vr':
                base_name.append(eval(i + ".base_name"))
                menu_mode.append(eval(i + ".menu_mode"))
                art_dir.append(i)
                vr_sources = zip(base_name, menu_mode, art_dir)
        except:
            pass

    if vr_sources:
        dirlst = []
        for i in sorted(vr_sources):
            dirlst.append({
                'name': kodi.giveColor(i[0], 'white'),
                'url': None,
                'mode': i[1],
                'icon': specific_icon % i[2],
                'fanart': specific_fanart % i[2],
                'folder': True
            })

    buildDirectory(dirlst)
def movies():
    sources = __all__
    movies_sources = []
    base_name = []
    menu_mode = []
    art_dir = []
    sources = [i for i in sources]
    for i in sources:
        try:
            if eval(i + ".type") == 'movies':
                base_name.append(eval(i + ".base_name"))
                menu_mode.append(eval(i + ".menu_mode"))
                art_dir.append(i.replace('_movies', ''))
                movies_sources = zip(base_name, menu_mode, art_dir)
        except:
            pass

    if movies_sources:
        dirlst = []
        for i in sorted(movies_sources):
            dirlst.append({
                'name': kodi.giveColor(i[0], 'white'),
                'url': None,
                'mode': i[1],
                'icon': specific_icon % i[0].lower(),
                'fanart': specific_fanart % i[0].lower(),
                'folder': True
            })

    buildDirectory(dirlst)
def searchHistory(name, url):
    searches = []
    mode, site = url.split('|SPLIT|')
    mode = int(mode)

    lst = [('New Search...', mode, 'null', 'Search AdultFlix', True), ('Clear History', 15, 'url', None, False),
           ('Disable Search History', 16, None, None, False),
           ('################## Recent Searches #########################', 999, 'url', None, False)]

    conn = sqlite3.connect(searchdb)
    conn.text_factory = str
    c = conn.cursor()
    c.execute("SELECT * FROM terms ORDER BY ID DESC")

    for (id, got_term) in c.fetchall():
        lst += [(got_term, mode, 'search_term=' + got_term, got_term, True)]

    dirlst = []

    for i in lst:
        icon = search_icon
        fanart = kodi.addonfanart
        dirlst.append(
            {'name': kodi.giveColor(i[0], 'white'), 'url': '%s|SPLIT|%s' % (i[2], site), 'mode': i[1], 'icon': icon,
             'fanart': fanart, 'description': i[3], 'folder': i[4]})

    if dirlst: buildDirectory(dirlst)

    local_utils.setView('list')
def pictures():
    sources = __all__
    picture_sources = []
    base_name = []
    menu_mode = []
    art_dir = []
    sources = [i for i in sources if i != 'chaturbate']
    for i in sources:
        try:
            if eval(i + ".pictures_tag") == 1:
                base_name.append(eval(i + ".base_name"))
                menu_mode.append(eval(i + ".pic_men_mode"))
                art_dir.append(i)
                picture_sources = zip(base_name, menu_mode, art_dir)
        except:
            pass

    if picture_sources:
        dirlst = []
        for i in sorted(picture_sources):
            dirlst.append({
                'name': kodi.giveColor(i[0], 'white'),
                'url': None,
                'mode': i[1],
                'icon': specific_icon % i[2],
                'fanart': specific_fanart % i[2],
                'folder': True
            })

    buildDirectory(dirlst)
示例#9
0
def clearHistory():
    if os.path.isfile(historydb):
        choice = xbmcgui.Dialog().yesno(kodi.get_name(), kodi.giveColor('Would you like to clear all history?', 'white'))
        if choice:
            try:
                os.remove(historydb)
            except:
                kodi.notify(msg='Error removing history.')
    xbmc.executebuiltin("Container.Refresh")
示例#10
0
def multilinkselector(url):
    try:
        if len(url) == 1:
            url = url[0][1]
        else:
            sources = []

            for i in url:
                smu_file = False
                try:
                    if i[2]: smu_file = True
                except:
                    pass
                if (not smu_file):
                    c = client.request(i[1], output='headers')
                    sources += [(i[0], kodi.convertSize(int(c['Content-Length'])), i[1])]
                else:
                    try:
                        pattern = r'''(?:)(?:http|https)(?:\:\/\/|\:\/\/www.)([^\.]+)'''
                        domain = re.match(pattern, i[1])
                        domain = domain.group(1).title()
                    except:
                        domain = 'Resolve URL Link'
                    sources += [(i[0], domain, i[1])]

            quals = []
            srcs = []

            for i in sources:
                qual = '%s - [ %s ]' % (i[0], i[1])
                quals.append(kodi.giveColor(qual, 'white', True))
                srcs.append(i[2])

            selected = kodi.dialog.select('Select a quality.', quals)
            if selected < 0:
                kodi.notify(msg='No option selected.')
                return 'quit'
            else:
                url = srcs[selected]
        kodi.busy()
        try:
            if hmf.HostedMediaFile(url).valid_url():
                url = hmf.HostedMediaFile(url).resolve()
        except:
            pass
        kodi.idle()
        return url
    except:
        try:
            if hmf.HostedMediaFile(url[0][1]).valid_url():
                url = hmf.HostedMediaFile(url[0][1]).resolve()
            return url
        except:
            pass
def clearFavorites():
    if os.path.isfile(favoritesdb):
        choice = xbmcgui.Dialog().yesno(
            kodi.get_name(),
            kodi.giveColor('Would you like to clear all of your favorites?',
                           'white'))
        if choice:
            try:
                os.remove(favoritesdb)
            except:
                kodi.notify(msg='Error clearing favorites.')
    xbmc.executebuiltin("Container.Refresh")
示例#12
0
def parentalCheck():
    timestamp = None
    password = None

    conn = sqlite3.connect(parentaldb)
    conn.text_factory = str
    c = conn.cursor()
    c.execute("SELECT * FROM parental")

    for (passwd, timest) in c.fetchall():
        timestamp = timest
        password = passwd
    conn.close()

    session_time = int(kodi.get_setting('session_time'))

    if password:
        try:
            now = time.time()
            check = now - 60 * session_time
            if (not timestamp): timestamp = 0
        except:
            now = time.time()
            check = now - 60 * session_time
            timestamp = 0
    else:
        return

    if (timestamp < check):

        input = kodi.get_keyboard(
            'Please Enter Your Password - %s' % kodi.giveColor(
                '(%s Minute Session)' % str(session_time), 'red', True),
            hidden=True)
        if (not input):
            sys.exit(0)

        pass_one = hashlib.sha256(input).hexdigest()

        if password != pass_one:
            kodi.dialog.ok(kodi.get_name(),
                           "Sorry, the password you entered was incorrect.")
            sys.exit(0)
        else:
            delEntry(password)
            addEntry(password, now)
            kodi.dialog.ok(
                kodi.get_name(), 'Login successful!',
                'You now have a %s minute session before you will be asked for the password again.'
                % str(session_time))
    return
示例#13
0
def multi(r):

    r = [(re.findall('(?://)(?:www.)?([^.]+).', i)[0].title(), i) for i in r
         if hmf.HostedMediaFile(i).valid_url()]

    names = []
    srcs = []

    if len(r) > 1:
        for i in sorted(r, reverse=True):
            names.append(kodi.giveColor(i[0], 'white', True))
            srcs.append(i[1])
        selected = kodi.dialog.select('Select a link.', names)
        if selected < 0:
            kodi.notify(msg='No option selected.')
            kodi.idle()
            quit()
        else:
            url = srcs[selected]
            return url
    else:
        return r[0][1]
示例#14
0
def parentalControls():
    list = []
    password = None
    conn = sqlite3.connect(parentaldb)
    conn.text_factory = str
    c = conn.cursor()
    c.execute("SELECT * FROM parental")

    for (timest, passwd) in c.fetchall():
        timestamp = timest
        password = passwd
    conn.close()

    if password:
        c = [(kodi.giveColor('PARENTAL CONTROLS - ', 'white', True) +
              kodi.giveColor('ON', 'lime'), 999),
             (kodi.giveColor('Change Password', 'white'), 13),
             (kodi.giveColor('Disable Password', 'white'), 14)]
    else:
        c = [(kodi.giveColor('PARENTAL CONTROLS - ', 'white', True) +
              kodi.giveColor('OFF', 'orangered'), 999),
             (kodi.giveColor('Setup Parental Password', 'white'), 13)]

    for i in c:
        icon = parental_icon
        fanart = kodi.addonfanart
        list.append({
            'name': i[0],
            'url': 'none',
            'mode': i[1],
            'icon': icon,
            'fanart': fanart,
            'folder': False
        })

    if list: buildDirectory(list)
def mainSearch(url):
    if '|SPLIT|' in url: url, site = url.split('|SPLIT|')
    term = url
    if term == "null":  term = kodi.get_keyboard('Search %s' % kodi.get_name())

    if term:
        search_on_off = kodi.get_setting("search_setting")
        if search_on_off == "true":
            delTerm(term)
            addTerm(term)

        display_term = term
        term = quote_plus(term)
        term = term.lower()

        if site == 'all':
            sources = __all__
            search_sources = []
            for i in sources:
                try:
                    if eval(i + ".search_tag") == 1: search_sources.append(i)
                except:
                    pass

            if search_sources:
                i = 0
                source_num = 0
                failed_list = ''
                line1 = kodi.giveColor('Searching: ', 'white') + kodi.giveColor('%s', 'dodgerblue')
                line2 = kodi.giveColor('Found: %s videos', 'white')
                line3 = kodi.giveColor('Source: %s of ' + str(len(search_sources)), 'white')

                kodi.dp.create(kodi.get_name(), '', line2, '')
                xbmc.executebuiltin('Dialog.Close(busydialog)')
                for u in sorted(search_sources):
                    if kodi.dp.iscanceled(): break
                    try:
                        i += 1
                        progress = 100 * int(i) / len(search_sources)
                        kodi.dp.update(progress, line1 % u.title(), line2 % str(source_num), line3 % str(i))
                        search_url = eval(u + ".search_base") % term
                        try:
                            source_n = eval(u + ".content('%s',True)" % search_url)
                        except:
                            source_n = 0
                        try:
                            source_n = int(source_n)
                        except:
                            source_n = 0
                        if not source_n:
                            if failed_list == '':
                                failed_list += str(u).title()
                            else:
                                failed_list += ', %s' % str(u).title()
                        else:
                            source_num += int(source_n)
                    except:
                        pass
                kodi.dp.close()
                if failed_list != '':
                    kodi.notify(msg='%s failed to return results.' % failed_list, duration=4000, sound=True)
                    log_utils.log('Scrapers failing to return search results are :: : %s' % failed_list,
                                  xbmc.LOGERROR)
                else:
                    kodi.notify(msg='%s results found.' % str(source_num), duration=4000, sound=True)
                xbmcplugin.setContent(kodi.syshandle, 'movies')
                xbmcplugin.endOfDirectory(kodi.syshandle, cacheToDisc=True)
                local_utils.setView('search')
        else:
            search_url = eval(site + ".search_base") % term
            eval(site + ".content('%s')" % search_url)
    else:
        kodi.notify(msg='Blank searches are not allowed.')
        quit()
    def get_next_page(self,
                      mode,
                      url,
                      pattern,
                      site='',
                      parse=None,
                      pictures=False):

        try:
            dirlst = []
            icon = xbmc.translatePath(
                os.path.join('special://home/addons/script.adultflix.artwork',
                             'resources/art/main/next.png'))
            fanart = xbmc.translatePath(
                os.path.join('special://home/addons/script.adultflix.artwork',
                             'resources/art/%s/fanart.jpg' % site))
            if '|GOT_URL' in url:
                url = url.split('|GOT_URL')[0]
                dirlst.append({
                    'name': kodi.giveColor('Next Page -->', 'white'),
                    'url': url,
                    'mode': mode,
                    'icon': icon,
                    'fanart': fanart,
                    'description': 'Load More......',
                    'folder': True
                })
            else:
                r = client.request(url)
                url = re.findall(r'%s' % pattern, r)[0]
                if parse:
                    url = urljoin(parse, url)
                if '&amp;' in url: url = url.replace('&amp;', '&')
                dirlst.append({
                    'name': kodi.giveColor('Next Page -->', 'white'),
                    'url': url,
                    'mode': mode,
                    'icon': icon,
                    'fanart': fanart,
                    'description': 'Load More......',
                    'folder': True
                })
            if 'chaturbate' in url:
                if dirlst:
                    buildDirectory(dirlst, isVideo=True, chaturbate=True)
            elif pictures:
                if dirlst: buildDirectory(dirlst, pictures=True)
            else:
                if dirlst: buildDirectory(dirlst, isVideo=True)
        except Exception as e:
            log_utils.log(
                'Error getting next page for %s :: Error: %s' %
                (site.title(), str(e)), xbmc.LOGERROR)
            xbmcplugin.setContent(kodi.syshandle, 'movies')
            if 'chaturbate' in url:
                local_utils.setView('chaturbate')
            elif pictures:
                local_utils.setView('pictures')
            else:
                local_utils.setView('thumbs')
            xbmcplugin.endOfDirectory(kodi.syshandle, cacheToDisc=True)
    def get_list(self,
                 mode,
                 type,
                 url,
                 title_pattern,
                 url_pattern,
                 icon_pattern=None,
                 site=None,
                 d_p1=None,
                 d_p2=None,
                 d_p3=None,
                 parse=None,
                 cache_time=None,
                 searched=False,
                 stopend=False,
                 isVideo=False,
                 isDownloadable=False):

        if cache_time:
            r = cache.get(client.request, cache_time, url)
        else:
            r = client.request(url)

        if 're|' in d_p3:
            d_p3 = d_p3.replace('re|', '')
            r = dom_parser2.parse_dom(r, d_p1, {d_p2: re.compile('%s' % d_p3)})
        else:
            r = dom_parser2.parse_dom(r, d_p1, {d_p2: d_p3})

        if r:

            dirlst = []

            for i in r:
                name = re.findall(r'%s' % title_pattern, i.content)[0]
                name = kodi.sortX(i[1].encode('utf-8'))
                url = re.findall(r'%s' % url_pattern, i.content)[0]
                if icon_pattern:
                    iconimage = re.findall(r'%s' % icon_pattern, i.content)[0]
                elif site:
                    iconimage = xbmc.translatePath(
                        os.path.join(
                            'special://home/addons/script.adultflix.artwork',
                            'resources/art/%s/icon.png' % site))
                else:
                    iconimage = xbmc.translatePath(
                        os.path.join('special://home/addons/' + kodi.get_id(),
                                     'icon.png'))
                fanarts = xbmc.translatePath(
                    os.path.join(
                        'special://home/addons/script.adultflix.artwork',
                        'resources/art/%s/fanart.jpg' % site))
                if parse:
                    link, tag = parse.split('|SPLIT|')
                    if tag == 'url':
                        url = urljoin(link, url)
                    elif tag == 'icon':
                        iconimage = urljoin(link, iconimage)
                    else:
                        url = urljoin(link, url)
                        iconimage = urljoin(link, iconimage)
                if site: url += '|SPLIT|' + site
                if type == 'dir':
                    dirlst.append({
                        'name': kodi.giveColor(name, 'white'),
                        'url': url,
                        'mode': mode,
                        'icon': iconimage,
                        'fanart': fanarts,
                        'description': name,
                        'folder': True
                    })
                else:
                    dirlst.append({
                        'name': kodi.giveColor(name, 'white'),
                        'url': url,
                        'mode': mode,
                        'icon': iconimage,
                        'fanart': fanarts,
                        'description': name,
                        'folder': False
                    })

            if dirlst:
                if stopend:
                    buildDirectory(dirlst,
                                   stopend=True,
                                   isVideo=isVideo,
                                   isDownloadable=isDownloadable)
                else:
                    buildDirectory(dirlst,
                                   isVideo=isVideo,
                                   isDownloadable=isDownloadable)
def getDownloads():

    if not os.path.exists(download_folder):
        os.makedirs(download_folder)

    dirlist = []
    lst = [(kodi.giveColor('Download Location: ', 'white') + 'file_path' +
            kodi.giveColor(str(download_folder), 'violet'), None, 19,
            download_icon, False),
           (kodi.giveColor('Change Download Location',
                           'white'), None, 19, download_icon, False),
           ('-----------------------------------------------', None, 999,
            download_icon, False)]

    extensions = ['.mp4']

    for file in os.listdir(download_folder):
        for extension in extensions:
            if file.endswith('.tmp_mp4'):
                try:
                    os.remove(os.path.join(download_folder, file))
                except:
                    pass
            if file.endswith(extension):
                name = unquote_plus(file)
                lst += [
                    (kodi.giveColor(str(name), 'white'),
                     os.path.join(download_folder, file), 803, None, True),
                ]

    conn = sqlite3.connect(downloaddb)
    conn.text_factory = str
    c = conn.cursor()
    for i in lst:
        find_string = i[0]
        if i[1]:
            try:
                find_string = find_string.replace('.mp4', '')
                find_string = kodi.stripColor(find_string)
                c.execute("SELECT image FROM downloads WHERE name = '%s'" %
                          find_string)
                icon = c.fetchone()[0]
            except:
                icon = None
        else:
            icon = i[3]
        dirlist.append({
            'name': find_string,
            'url': i[1],
            'mode': i[2],
            'icon': icon,
            'fanart': None,
            'folder': False,
            'isDownloaded': i[4]
        })

    if c:
        c.close()

    if len(lst) < 4:
        dirlist.append({
            'name': kodi.giveColor('No Downloads Found', 'white'),
            'url': 'None',
            'mode': 999,
            'icon': download_icon,
            'fanart': None,
            'folder': False
        })

    buildDirectory(dirlist)
def buildDir(items,
             content='dirs',
             cm=None,
             search=False,
             stopend=False,
             isVideo=False,
             isDownloadable=False,
             cache=True,
             chaturbate=False,
             pictures=False):
    if items is None or len(items) == 0:
        kodi.busy()
        sys.exit()

    if cm is None:
        cm = []

    sysaddon = sys.argv[0]
    syshandle = int(sys.argv[1])

    if chaturbate:
        import sqlite3
        databases = xbmc.translatePath(
            os.path.join(kodi.datafolder, 'databases'))
        chaturbatedb = xbmc.translatePath(
            os.path.join(databases, 'chaturbate.db'))
        conn = sqlite3.connect(chaturbatedb)
        conn.text_factory = str
        c = conn.cursor()
        c.execute("SELECT * FROM chaturbate ORDER BY name ASC")
        chat_urls = []
        for (chat_name, chat_url, chat_icon) in c.fetchall():
            chat_urls.append(chat_url)

    for i in items:

        try:
            name = i['name']

            if 'file_path' not in name:
                try:
                    name = client.replaceHTMLCodes(name)
                    name = kodi.sortX(name)
                except:
                    pass
            else:
                name = name.replace('file_path', '')

            item = xbmcgui.ListItem(label=name)

            try:
                if i['description']: description = i['description']
            except:
                description = name

            try:
                description = client.replaceHTMLCodes(description)
                description = kodi.sortX(description)
            except:
                pass

            kodi.giveColor(description, 'white', True)
            if pictures:
                item.setInfo('picture', {'title': name, 'plot': description})
            else:
                item.setInfo('video', {'title': name, 'plot': description})

            try:
                name = quote_plus(name)
            except:
                name = name.replace(' ', '+')

            try:
                if i['url']:
                    url = i['url']
                else:
                    url = 'none'
            except:
                url = 'none'
            if i['icon'] == None:
                thumb = kodi.addonicon
            else:
                thumb = i['icon']
            if i['fanart'] == None:
                fanart = kodi.addonicon
            else:
                fanart = i['fanart']
            if (not thumb == 'local') and (not fanart == 'local'):
                item.setArt({'icon': thumb, 'thumb': thumb, 'fanart': fanart})
            else:
                item.setArt({'icon': url, 'thumb': url, 'fanart': fanart})

            try:
                if i['folder']:
                    _folder = True
                else:
                    _folder = False
            except:
                _folder = True

            try:
                if i['isDownloaded']:
                    isDownloaded = True
                else:
                    isDownloaded = False
            except:
                isDownloaded = False

            if not isDownloadable:
                try:
                    if i['isDownloadable']:
                        isDownloadable = True
                    else:
                        isDownloadable = False
                except:
                    isDownloadable = False

            if 'typeid=history' in url:
                url = url.replace('typeid=history', '')
                history = '%s?url=%s&mode=%s' \
                          % (sysaddon, quote_plus(url), str('24'))
                htext = "Remove from History"
                cm.append(('%s' % htext, 'xbmc.RunPlugin(' + history + ')'))

            if 'search_term=' in url:
                search_term = '%s?url=%s&mode=%s' \
                              % (sysaddon, quote_plus(url), str('25'))
                stext = "Remove Search Term"
                cm.append(
                    ('%s' % stext, 'xbmc.RunPlugin(' + search_term + ')'))
                url = url.replace('search_term=', '')

            u = '%s?url=%s&mode=%s&name=%s&iconimage=%s&fanart=%s' % (
                sysaddon, quote_plus(url), str(
                    i['mode']), name, quote_plus(thumb), quote_plus(fanart))

            if chaturbate:
                if '|CHAT|' in url:
                    check_url = url.split('|CHAT|')[0]
                else:
                    check_url = url.split('|SPLIT|')[0]
                log_utils.log('URL IS %s' % (check_url), xbmc.LOGERROR)
                if check_url in str(chat_urls):
                    chat = 'del'
                else:
                    chat = 'add'

                chat_compiled = '%s?url=%s&mode=%s&name=%s&iconimage=%s&chat=%s&chatmode=%s&folder=%s' % (
                    sysaddon, quote_plus(check_url), str('101'), name,
                    quote_plus(thumb), chat, str(i['mode']), str(_folder))

                if chat == 'add':
                    ctext = "Add to"
                elif chat == 'del':
                    ctext = "Remove from"
                cm.append(('%s Chaturbate Monitoring' % ctext,
                           'xbmc.RunPlugin(' + chat_compiled + ')'))

            try:
                if i['fav']:
                    fav = i['fav']
                else:
                    fav = 'add'
            except:
                fav = 'add'

            try:
                if i['cm']:
                    for cmitems in i['cm']:
                        log_utils.log('%s' % (cmitems[1]), xbmc.LOGNOTICE)
                        cm.append(('%s' % cmitems[0],
                                   'xbmc.RunPlugin(' + cmitems[1] + ')'))
            except:
                pass

            favorite = '%s?url=%s&mode=%s&name=%s&iconimage=%s&fav=%s&favmode=%s&folder=%s' % (
                sysaddon, quote_plus(url), str('100'), name, quote_plus(thumb),
                fav, str(i['mode']), str(_folder))

            if fav == 'add':
                ftext = "Add to"
            elif fav == 'del':
                ftext = "Remove from"
            cm.append(('%s %s Favorites' % (ftext, kodi.get_name()),
                       'xbmc.RunPlugin(' + favorite + ')'))

            if isDownloadable:
                dwnld = '%s?url=%s&mode=%s&name=%s&iconimage=%s' % (
                    sysaddon, quote_plus(url), str('26'), name,
                    quote_plus(thumb))
                cm.append(('Download Video', 'xbmc.RunPlugin(' + dwnld + ')'))
            if isDownloaded:
                rmdwnld = '%s?url=%s&mode=%s&name=%s' % (
                    sysaddon, quote_plus(url), str('28'), name)
                cm.append(('Delete Video', 'xbmc.RunPlugin(' + rmdwnld + ')'))

            open_set = '%s?mode=%s' % (sysaddon, str('19'))
            stext = "Open AdultFlix Settings"
            cm.append(('%s' % stext, 'xbmc.RunPlugin(' + open_set + ')'))

            if isDownloadable:
                view_type = 'thumb'
            elif pictures:
                view_type = 'picture'
            elif chaturbate:
                view_type = 'chaturbate'
            else:
                view_type = 'list'
            view_compile = '%s?mode=%s&name=%s' % (sysaddon, str('44'),
                                                   view_type)
            cm.append(
                ('Set %s to this view mode by default.' % view_type.title(),
                 'xbmc.RunPlugin(' + view_compile + ')'))

            if cm:
                item.addContextMenuItems(cm, replaceItems=False)
                cm = []

            if isVideo:
                codec_info = {'codec': 'h264'}
                item.addStreamInfo('video', codec_info)

            xbmcplugin.addDirectoryItem(handle=syshandle,
                                        url=u,
                                        listitem=item,
                                        isFolder=_folder)

        except Exception as e:
            log_utils.log(
                'Error adding item %s in BuildDir function ( %s %s ):: Error: %s'
                % (name, url, thumb, str(e)), xbmc.LOGERROR)

    if not stopend:
        if chaturbate:
            xbmcplugin.setContent(kodi.syshandle, 'movies')
            setView('chaturbate')
        elif pictures:
            xbmcplugin.setContent(kodi.syshandle, 'movies')
            setView('pictures')
        elif isVideo:
            xbmcplugin.setContent(kodi.syshandle, 'movies')
            setView('thumbs')
        else:
            xbmcplugin.setContent(kodi.syshandle, 'movies')
            setView('list')
    if not search and not stopend:
        if cache:
            xbmcplugin.endOfDirectory(syshandle, cacheToDisc=True)
        else:
            xbmcplugin.endOfDirectory(syshandle, cacheToDisc=False)
示例#20
0
def mainMenu():

    art = xbmc.translatePath(
        os.path.join(
            'special://home/addons/script.adultflix.artwork/resources/art/',
            'main/%s.png'))

    dirlst = []
    c = []

    c += [
        (kodi.giveColor('Welcome to AdultFlix Version %s' % kodi.get_version(),
                        'blue', True),
         xbmc.translatePath(
             os.path.join(kodi.addonfolder,
                          'resources/files/information.txt')), 17, 'icon',
         'All issues must be reported at https://github.com/tvaddonsco/plugin.video.adultflix/issues or I will not know the issues exist. '
         'I will not provide support at any other location as one central place for everyone to see and discuss issues benefits everyone.',
         False),
        (kodi.giveColor(
            kodi.countGitHubIssues(
                'https://github.com/tvaddonsco/plugin.video.adultflix/issues'),
            'blue', True) +
         kodi.giveColor(' | Click To View Issues', 'white', True), None, 34,
         'report',
         'All issues must be reported at https://github.com/tvaddonsco/plugin.video.adultflix/issues or I will not know the issues exist. '
         'I will not provide support at any other location as one central place for everyone to see and discuss issues benefits everyone.',
         False), ('Search...', None, 29, 'search', 'Search AdultFlix', True),
        ('Live Cams', None, 37, 'webcams', 'Live Cams', True),
        ('Tubes', None, 4, 'tubes', 'Videos', True),
        ('Scenes', None, 36, 'scenes', 'XXX Scenes', True),
        ('Movies', None, 43, 'movies', 'XXX Movies', True),
        ('Virtual Reality', None, 42, 'vr', 'XXX Virtual Reality', True),
        ('Hentai', None, 39, 'hentai', 'Hentai', True),
        ('Vintage', None, 270, 'vintage', 'Vintage', True),
        ('Fetish', None, 40, 'fetish', 'Fetish', True),
        ('Pictures', None, 35, 'pics', 'Pictures', True),
        ('Comics', None, 41, 'comics', 'Comics', True),
        ('Parental Controls', None, 5, 'parental_controls',
         'View/Change Parental Control Settings.', True),
        ('Your History', None, 20, 'history', 'View Your History.', True),
        ('Your Favourites', None, 23, 'favourites', 'View Your Favourites.',
         True),
        ('Your Downloads', None, 27, 'downloads', 'View Your Downloads.',
         True),
        ('Your Settings', None, 19, 'settings', 'View/Change Addon Settings.',
         False),
        ('View Disclaimer',
         xbmc.translatePath(
             os.path.join(kodi.addonfolder, 'resources/files/disclaimer.txt')),
         17, 'disclaimer', 'View AdultFlix Disclaimer.', False),
        ('View Addon Information',
         xbmc.translatePath(
             os.path.join(kodi.addonfolder,
                          'resources/files/information.txt')), 17,
         'addon_info', 'View AdultFlix Information.', False),
        ('View Changelog',
         xbmc.translatePath(os.path.join(kodi.addonfolder, 'changelog.txt')),
         17, 'changelog', 'View AdultFlix Changelog.', False),
        ('Debug Versions', None, 45, 'addon_info',
         'View the versions of AdultFlix and its dependencies for debugging.',
         True),
        ('RESET AdultFlix', None, 18, 'reset',
         'Reset AdultFlix to Factory Settings.', False),
        (kodi.giveColor(
            'Report Issues @ https://github.com/tvaddonsco/plugin.video.adultflix/issues',
            'violet', True),
         xbmc.translatePath(
             os.path.join(kodi.addonfolder,
                          'resources/files/information.txt')), 17, 'report',
         'All issues must be reported at https://github.com/tvaddonsco/plugin.video.adultflix/issues or I will not know the issues exist. '
         'I will not provide support at any other location as one central place for everyone to see and discuss issues benefits everyone.',
         False)
    ]

    for i in c:
        icon = art % i[3]
        fanart = kodi.addonfanart
        dirlst.append({
            'name': kodi.giveColor(i[0], 'white'),
            'url': i[1],
            'mode': i[2],
            'icon': icon,
            'fanart': fanart,
            'description': i[4],
            'folder': i[5]
        })

    buildDirectory(dirlst, cache=False)
def depVersions():
    try:
        xbmc_version = xbmc.getInfoLabel("System.BuildVersion").split(' ')[0]
    except:
        xbmc_version = 'Unknown'
    try:
        xbmc_builddate = xbmc.getInfoLabel('System.BuildDate')
    except:
        xbmc_builddate = 'Unknown'
    try:
        xbmc_language = xbmc.getInfoLabel('System.Language')
    except:
        xbmc_language = 'Unknown'
    try:
        python_version = sys.version.split(' ')[0]
    except:
        python_version = 'Unknown'

    try:
        xml1 = client.request(
            'https://raw.githubusercontent.com/tvaddonsco/tva-adult-repo/master/addons.xml'
        )
        xml2 = client.request(
            'https://raw.githubusercontent.com/tvaddonsco/tva-adult-repo/master/addons.xml'
        )
        lst = [('plugin.video.adultflix'), ('script.adultflix.scrapers'),
               ('script.adultflix.artwork'), ('script.module.librarypack'),
               ('script.module.resolveurl'), ('script.module.resolveurl.xxx')]

        c = []
        c += [(kodi.giveColor('Kodi Version: ', 'white', True) +
               kodi.giveColor(xbmc_version, 'pink'), kodi.addonicon,
               kodi.addonfanart, xbmc_version)]
        c += [(kodi.giveColor('Python Version: ', 'white', True) +
               kodi.giveColor(python_version, 'pink'), kodi.addonicon,
               kodi.addonfanart, python_version)]
        c += [(kodi.giveColor('Kodi Build Date: ', 'white', True) +
               kodi.giveColor(xbmc_builddate, 'pink'), kodi.addonicon,
               kodi.addonfanart, xbmc_builddate)]
        c += [(kodi.giveColor('Kodi Language: ', 'white', True) +
               kodi.giveColor(xbmc_language, 'pink'), kodi.addonicon,
               kodi.addonfanart, xbmc_language)]

        for i in lst:
            addon_name = xbmcaddon.Addon('%s' % i).getAddonInfo('name')
            addon_id = xbmcaddon.Addon('%s' % i).getAddonInfo('id')
            addon_version = xbmcaddon.Addon('%s' % i).getAddonInfo('version')
            addon_description = xbmcaddon.Addon('%s' %
                                                i).getAddonInfo('description')
            pattern = r'''id=['"]%s['"][\w\s='"-]+version=['"]([^'"]+)['"]''' % addon_id
            try:
                cur_ver = re.findall(pattern, xml1)[0]
            except:
                try:
                    cur_ver = re.findall(pattern, xml2)[0]
                except:
                    cur_ver = 'Unknown'

            in_v = int(addon_version.replace('.', ''))
            try:
                cur_v = int(cur_ver.replace('.', ''))
                if in_v < cur_v:
                    ver_color = 'orangered'
                else:
                    ver_color = 'lime'
            except:
                ver_color = 'lime'
            icon = xbmc.translatePath(
                os.path.join('special://home/addons', addon_id + '/icon.png'))
            c += [(kodi.giveColor(addon_name, 'white', True) +
                   kodi.giveColor('| Installed: ', 'white') +
                   kodi.giveColor(addon_version, ver_color, True) + ' - ' +
                   kodi.giveColor('Available: ', 'white', True) +
                   kodi.giveColor(cur_ver, 'pink', True), icon,
                   kodi.addonfanart, addon_description)]

        dirlst = []

        for e in c:
            dirlst.append({
                'name': kodi.giveColor(e[0], 'white'),
                'url': 'None',
                'mode': 999,
                'icon': e[1],
                'fanart': e[2],
                'description': e[3],
                'folder': False
            })

        buildDir(dirlst)
    except:
        kodi.notify(msg='Error opening directory.', sound=True)
        quit()