示例#1
0
def parentalOff():
    input = kodi.get_keyboard('Please Enter Your Password', hidden=True)
    if not input:
        kodi.dialog.ok(kodi.get_name(), "Sorry, no password was entered.")
        sys.exit(0)
    pass_one = hashlib.sha256(input).hexdigest()

    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()

    if password == pass_one:
        try:
            try:
                os.remove(parentaldb)
            except:
                pass
            kodi.dialog.ok(kodi.get_name(),
                           'Parental controls have been disabled.')
            xbmc.executebuiltin("Container.Refresh")
        except:
            kodi.dialog.ok(
                kodi.get_name(),
                'There was an error disabling the parental controls.')
            xbmc.executebuiltin("Container.Refresh")
    else:
        kodi.dialog.ok(kodi.get_name(),
                       "Sorry, the password you entered was incorrect.")
        quit()
示例#2
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
示例#3
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")
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")
def hard_reset():
    viewDialog(
        xbmc.translatePath(
            os.path.join(kodi.addonfolder, 'resources/files/reset.txt')))
    choice = xbmcgui.Dialog().yesno(
        "[COLOR orangered][B]RESET AdultFlix?[/B][/COLOR]",
        '[COLOR white]ARE YOU SURE YOU WANT TO RETURN AdultFlix TO THE DEFAULT STATE AND LOSE ALL YOUR INFORMATION?[/COLOR]'
    )
    if choice:
        try:
            shutil.rmtree(kodi.datafolder)
        except:
            kodi.dialog.ok(
                kodi.get_name(),
                "[COLOR white]There was an error deleting deleting the data directory.[/COLOR]"
            )
            quit()
        kodi.dialog.ok(
            kodi.get_name(),
            "[COLOR white]AdultFlix has been reset to the factory state.[/COLOR]",
            "[COLOR white]Press OK to continue.[/COLOR]")
        xbmc.executebuiltin("Container.Refresh")
示例#6
0
def parentalPin():
    input = kodi.get_keyboard('Please Set Password', hidden=True)
    if not input:
        kodi.dialog.ok(kodi.get_name(), "Sorry, no password was entered.")
        sys.exit(0)

    pass_one = input

    input = kodi.get_keyboard('Please Confirm Your Password', hidden=True)
    if not input:
        kodi.dialog.ok(kodi.get_name(), "Sorry, no password was entered.")
        sys.exit(0)

    pass_two = input

    if pass_one == pass_two:
        writeme = hashlib.sha256(pass_one).hexdigest()
        addEntry(writeme, None)
        kodi.dialog.ok(kodi.get_name(), 'Parental control has been enabled.')
        xbmc.executebuiltin("Container.Refresh")
    else:
        kodi.dialog.ok(kodi.get_name(),
                       'The passwords do not match, please try again.')
        sys.exit(0)
    def checkAge(self):

        choice = kodi.dialog.yesno(
            kodi.get_name(),
            'To use this addon you you must be legally allowed to under the laws of your State/Country. By pressing I Agree you accept that you are legally allowed to view adult content.',
            yeslabel='I Agree',
            nolabel='Exit')
        if choice:
            try:
                with open(self.firstRunFile, mode='w'):
                    pass
            except:
                pass
        else:
            sys.exit(1)
def download(url, name, icon, dest, dp=None):
    xbmc.executebuiltin("Dialog.Close(busydialog)")
    if '|' in url:
        url = url.split('|')[0]
    if not dp:
        dp = kodi.dp
        dp.create(kodi.get_name(), "Downloading: %s" % name, ' ', ' ')
    dp.update(0)
    start_time = time.time()
    log_utils.log('Attempting to download :: %s' % url, xbmc.LOGNOTICE)
    urlretrieve(url, dest,
                lambda nb, bs, fs: _pbhook(dest, nb, bs, fs, dp, start_time))
    addDownload(name, url, icon)
    kodi.notify(msg='Download Complete', sound=True)
    log_utils.log('Download complete.', xbmc.LOGNOTICE)
    finish_up(dest)
示例#9
0
class Logger(object):
    __loggers = {}
    __name = kodi.get_name()
    __addon_debug = kodi.get_setting('addon_debug') == 'true'
    __debug_on = _is_debugging()
    __disabled = set()

    @staticmethod
    def get_logger(name=None):
        if name not in Logger.__loggers:
            Logger.__loggers[name] = Logger()

        return Logger.__loggers[name]

    def disable(self):
        if self not in Logger.__disabled:
            Logger.__disabled.add(self)

    def enable(self):
        if self in Logger.__disabled:
            Logger.__disabled.remove(self)

    def log(self, msg, level=xbmc.LOGDEBUG):
        # if debug isn't on, skip disabled loggers unless addon_debug is on
        if not self.__debug_on:
            if self in self.__disabled:
                return
            elif level == xbmc.LOGDEBUG:
                if self.__addon_debug:
                    level = xbmc.LOGNOTICE
                else:
                    return

        try:
            if isinstance(msg, unicode):
                msg = '%s (ENCODED)' % (msg.encode('utf-8'))

            kodi._log('%s: %s' % (self.__name, msg), level)

        except Exception as e:
            try:
                kodi._log('Logging Failure: %s' % (e), level)
            except:
                pass  # just give up
示例#10
0
'''

from __future__ import absolute_import
import time
from packlib import kodi
import cProfile
import pstats
from kodi_six import xbmc
import six

# Moved attributes found on six library
basestring = six.string_types
unicode = six.text_type
StringIO = six.StringIO

name = kodi.get_name()
enabled_comp = kodi.get_setting('enabled_comp')
if enabled_comp:
    enabled_comp = enabled_comp.split(',')
else:
    enabled_comp = None


def log(msg, level=xbmc.LOGDEBUG, component=None):
    req_level = level
    # override message level to force logging when addon logging turned on
    if kodi.get_setting('addon_debug') == 'true' and level == xbmc.LOGDEBUG:
        level = xbmc.LOGNOTICE

    try:
        if isinstance(msg, unicode):
示例#11
0
def download_media(url, path, file_name, translations, progress=None):
    try:
        if progress is None:
            progress = int(kodi.get_setting('down_progress'))

        i18n = translations.i18n
        active = not progress == PROGRESS.OFF
        background = progress == PROGRESS.BACKGROUND

        with kodi.ProgressDialog(kodi.get_name(),
                                 i18n('downloading') % (file_name),
                                 background=background,
                                 active=active) as pd:
            try:
                headers = dict([
                    item.split('=') for item in (url.split('|')[1]).split('&')
                ])
                for key in headers:
                    headers[key] = unquote(headers[key])
            except:
                headers = {}
            if 'User-Agent' not in headers: headers['User-Agent'] = BROWSER_UA
            request = Request(url.split('|')[0], headers=headers)
            response = urlopen(request)
            if 'Content-Length' in response.info():
                content_length = int(response.info()['Content-Length'])
            else:
                content_length = 0

            file_name += '.' + get_extension(url, response)
            full_path = os.path.join(path, file_name)
            logger.log('Downloading: %s -> %s' % (url, full_path),
                       xbmc.LOGDEBUG)

            path = kodi.translate_path(xbmc.makeLegalFilename(path))
            try:
                try:
                    xbmcvfs.mkdirs(path)
                except:
                    os.makedirs(path)
            except Exception as e:
                logger.log('Path Create Failed: %s (%s)' % (e, path),
                           xbmc.LOGDEBUG)

            if not path.endswith(os.sep): path += os.sep
            if not xbmcvfs.exists(path):
                raise Exception(i18n('failed_create_dir'))

            file_desc = xbmcvfs.File(full_path, 'w')
            total_len = 0
            cancel = False
            while True:
                data = response.read(CHUNK_SIZE)
                if not data:
                    break

                if pd.is_canceled():
                    cancel = True
                    break

                total_len += len(data)
                if not file_desc.write(data):
                    raise Exception(i18n('failed_write_file'))

                percent_progress = total_len * 100 / content_length if content_length > 0 else 0
                logger.log(
                    'Position : %s / %s = %s%%' %
                    (total_len, content_length, percent_progress),
                    xbmc.LOGDEBUG)
                pd.update(percent_progress)

            file_desc.close()

        if not cancel:
            kodi.notify(msg=i18n('download_complete') % (file_name),
                        duration=5000)
            logger.log('Download Complete: %s -> %s' % (url, full_path),
                       xbmc.LOGDEBUG)

    except Exception as e:
        logger.log(
            'Error (%s) during download: %s -> %s' % (str(e), url, file_name),
            xbmc.LOGERROR)
        kodi.notify(msg=i18n('download_error') % (str(e), file_name),
                    duration=5000)
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 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)
def setViewCM(viewtype):
    window = xbmcgui.Window(xbmcgui.getCurrentWindowId())
    viewid = str(window.getFocusId())
    xbmcaddon.Addon().setSetting("%s_view" % (viewtype), viewid)
    kodi.notify(kodi.get_name(),
                "%s view has been set to (%s)." % (viewtype.title(), viewid))