Beispiel #1
0
 def clearCache(self):
     control.idle()
     yes = control.yesnoDialog(control.lang(32056).encode('utf-8'), '', '')
     if not yes: return
     from resources.lib.smodules import cache
     cache.clear()
     control.infoDialog(control.lang(32057).encode('utf-8'), sound=True, icon='INFO')
Beispiel #2
0
def addView(content):
    try:
        skin = control.skin
        skinPath = control.skinPath
        xml = os.path.join(skinPath, 'addon.xml')
        file = control.openFile(xml)
        read = file.read().replace('\n', '')
        file.close()
        try:
            src = re.compile('defaultresolution="(.+?)"').findall(read)[0]
        except:
            src = re.compile('<res.+?folder="(.+?)"').findall(read)[0]
        src = os.path.join(skinPath, src)
        src = os.path.join(src, 'MyVideoNav.xml')
        file = control.openFile(src)
        read = file.read().replace('\n', '')
        file.close()
        views = re.compile('<views>(.+?)</views>').findall(read)[0]
        views = [int(x) for x in views.split(',')]
        for view in views:
            label = control.infoLabel('Control.GetLabel(%s)' % (view))
            if not (label == '' or label == None): break
        record = (skin, content, str(view))
        control.makeFile(control.dataPath)
        dbcon = database.connect(control.viewsFile)
        dbcur = dbcon.cursor()
        dbcur.execute("CREATE TABLE IF NOT EXISTS views ("
                      "skin TEXT, "
                      "view_type TEXT, "
                      "view_id TEXT, "
                      "UNIQUE(skin, view_type)"
                      ");")
        dbcur.execute(
            "DELETE FROM views WHERE skin = '%s' AND view_type = '%s'" %
            (record[0], record[1]))
        dbcur.execute("INSERT INTO views Values (?, ?, ?)", record)
        dbcon.commit()

        viewName = control.infoLabel('Container.Viewmode')
        skinName = control.addon(skin).getAddonInfo('name')
        skinIcon = control.addon(skin).getAddonInfo('icon')

        control.infoDialog(viewName,
                           heading=skinName,
                           sound=True,
                           icon=skinIcon)
    except:
        return
Beispiel #3
0
    def clearSources(self):
        try:
            control.idle()

            yes = control.yesnoDialog(
                control.lang(32407).encode('utf-8'), '', '')
            if not yes: return

            control.makeFile(control.dataPath)
            dbcon = database.connect(control.providercacheFile)
            dbcur = dbcon.cursor()
            dbcur.execute("DROP TABLE IF EXISTS rel_src")
            dbcur.execute("VACUUM")
            dbcon.commit()

            control.infoDialog(control.lang(32408).encode('utf-8'),
                               sound=True,
                               icon='INFO')
        except:
            pass
Beispiel #4
0
def manager(name, imdb, tvdb, content):
    try:
        post = {
            "movies": [{
                "ids": {
                    "imdb": imdb
                }
            }]
        } if content == 'movie' else {
            "shows": [{
                "ids": {
                    "tvdb": tvdb
                }
            }]
        }

        items = [(control.lang(32516).encode('utf-8'), '/sync/collection')]
        items += [(control.lang(32517).encode('utf-8'),
                   '/sync/collection/remove')]
        items += [(control.lang(32518).encode('utf-8'), '/sync/watchlist')]
        items += [(control.lang(32519).encode('utf-8'),
                   '/sync/watchlist/remove')]
        items += [(control.lang(32520).encode('utf-8'),
                   '/users/me/lists/%s/items')]

        result = getTrakt('/users/me/lists')
        result = json.loads(result)
        lists = [(i['name'], i['ids']['slug']) for i in result]
        lists = [lists[i // 2] for i in range(len(lists) * 2)]
        for i in range(0, len(lists), 2):
            lists[i] = ((control.lang(32521) % lists[i][0]).encode('utf-8'),
                        '/users/me/lists/%s/items' % lists[i][1])
        for i in range(1, len(lists), 2):
            lists[i] = ((control.lang(32522) % lists[i][0]).encode('utf-8'),
                        '/users/me/lists/%s/items/remove' % lists[i][1])
        items += lists

        select = control.selectDialog([i[0] for i in items],
                                      control.lang(32515).encode('utf-8'))

        if select == -1:
            return
        elif select == 4:
            t = control.lang(32520).encode('utf-8')
            k = control.keyboard('', t)
            k.doModal()
            new = k.getText() if k.isConfirmed() else None
            if (new == None or new == ''): return
            result = getTrakt('/users/me/lists',
                              post={
                                  "name": new,
                                  "privacy": "private"
                              })

            try:
                slug = json.loads(result)['ids']['slug']
            except:
                return control.infoDialog(control.lang(32515).encode('utf-8'),
                                          heading=str(name),
                                          sound=True,
                                          icon='ERROR')
            result = getTrakt(items[select][1] % slug, post=post)
        else:
            result = getTrakt(items[select][1], post=post)

        icon = control.infoLabel(
            'ListItem.Icon') if not result == None else 'ERROR'

        control.infoDialog(control.lang(32515).encode('utf-8'),
                           heading=str(name),
                           sound=True,
                           icon=icon)
    except:
        return
Beispiel #5
0
 def infoCheck(self, version):
     try:
         control.infoDialog('www.tvaddons.ag', control.lang(32074).encode('utf-8'), time=5000, sound=False)
         return '1'
     except:
         return '1'
Beispiel #6
0
 def accountCheck(self):
     if traktCredentials == False and imdbCredentials == False:
         control.idle()
         control.infoDialog(control.lang(32042).encode('utf-8'), sound=True, icon='WARNING')
         sys.exit()
Beispiel #7
0
 def errorForSources(self):
     control.infoDialog(control.lang(32401).encode('utf-8'),
                        sound=False,
                        icon='INFO')