Пример #1
0
    def update_known_providers(self):
        provider_types = ['torrent', 'hosters']
        sys.path.append(tools.dataPath)
        import providers

        all_providers = providers.get_all(self.language)
        all_providers = {
            'torrent': all_providers[0],
            'hosters': all_providers[1]
        }

        for provider_type in provider_types:
            for provider in all_providers[provider_type]:
                if not self._provider_exists(provider[1], provider[2]):
                    database.add_provider(provider[1], provider[2], 'enabled',
                                          self.language, provider_type)

        for known_provider in self.known_providers:
            provider_exists = False
            for provider in all_providers[known_provider['provider_type']]:
                if known_provider['provider_name'] == provider[
                        1] and known_provider['package'] == provider[2]:
                    provider_exists = True
                    break

            if not provider_exists:
                database.remove_individual_provider(
                    known_provider['provider_name'], known_provider['package'])

        self.poll_database()
Пример #2
0
    def adjust_providers(self, status, package_disable=False):
        if status == 'disabled':
            action = 'enabled'
        if status == 'enabled':
            action = 'disabled'
        if len(self.known_providers) == 0:
            self.known_providers = database.get_providers()
        packages = list(set([provider['package'] for provider in self.known_providers]))
        selection = tools.showDialog.select("%s: %s Providers" %
                                            (tools.addonName, action[:-1].title()), packages)

        if selection == -1:
            return

        providers = [i for i in self.known_providers if i['package'] == packages[selection] and i['status'] == status]

        if package_disable is False:
            display_list = ["%s - %s" % (tools.colorString(i['provider_name'].upper()), i['provider_type'].title())
                            for i in providers if i['status'] == status]

            selection = tools.showDialog.multiselect("%s: %s Providers" %
                                                     (tools.addonName, action[:-1].title()), display_list)

            if selection is None:
                return

            for i in selection:
                provider = providers[i]
                database.add_provider(provider['provider_name'], provider['package'], action, self.language,
                                   provider['provider_type'])

        elif package_disable is True:
            for i in providers:
                database.add_provider(i['provider_name'], i['package'], action, self.language, i['provider_type'])
    def update_known_providers(self):
        provider_types = ['torrent', 'hosters']
        sys.path.append(tools.dataPath)
        import providers

        providers = providers.get_all(self.language)

        if len(self.pre_update_collection) > 0:
            pack_name = self.pre_update_collection[0]['package']

            hosters = providers[1]
            torrent = providers[0]

            for provider_type in range(len(provider_types)):
                for i in providers[provider_type]:
                    provider_name = i[1]
                    old_setting = [x for x in self.pre_update_collection if
                                   x['provider_type'] == provider_types[provider_type] and
                                   x['package'] == pack_name and
                                   x['provider_name'] == provider_name]

                    if len(old_setting) > 0:
                        old_setting = old_setting[0]
                        database.add_provider(old_setting['provider_name'],
                                              old_setting['package'],
                                              old_setting['status'],
                                              old_setting['country'],
                                              old_setting['provider_type'])
                    else:
                        database.add_provider(i[1], i[2], 'enabled', self.language, provider_types[provider_type])

        else:
            if self.known_providers is None or len(self.known_providers) == 0:

                for provider in providers[0]:
                    tools.log('Adding Provider %s' % provider[1])
                    database.add_provider(provider[1], provider[2], 'enabled', self.language, 'torrent')
                for provider in providers[1]:
                    tools.log('Adding Provider %s' % provider[1])
                    database.add_provider(provider[1], provider[2], 'enabled', self.language, 'hoster')

            else:

                for i in range(2):
                    for provider in providers[i]:
                        existing = [existing for existing in self.known_providers
                                    if provider[2] == existing['package']\
                                    and provider[1] == existing['provider_name']\
                                    and existing['provider_type'] == provider_types[i]]


                        if len(existing) == 0:
                            tools.log('Adding Provider %s' % provider[1])
                            database.add_provider(provider[1], provider[2], 'enabled', self.language,
                                                  provider_types[i])
                            check = False


        self.known_providers = database.get_providers()
Пример #4
0
    def update_known_providers(self):
        provider_types = ['torrent', 'hosters']
        sys.path.append(tools.dataPath)
        import providers

        all_providers = providers.get_all(self.language)
        all_providers = {
            'torrent': all_providers[0],
            'hosters': all_providers[1]
        }

        for provider_type in provider_types:

            for provider in all_providers[provider_type]:
                database.add_provider(provider[1], provider[2], 'enabled',
                                      self.language, provider_type)

        self.known_providers = database.get_providers()
Пример #5
0
    def update_known_providers(self):
        sys.path.append(tools.dataPath)
        import providers
        providers = providers.get_all(self.language)

        if self.known_providers is None or len(self.known_providers) == 0:
            for provider in providers[0]:
                database.add_provider(provider[1], provider[2], 'enabled', self.language, 'torrent')
            for provider in providers[1]:
                database.add_provider(provider[1], provider[2], 'enabled', self.language, 'hoster')
            return

        for provider in providers[0]:
            check = False
            for kp in self.known_providers:
                if kp['country'] != self.language:
                    continue
                if kp['provider_type'] != 'torrent':
                    continue
                if provider[2] == kp['package'] and provider[1] == kp['provider_name']:
                    check = True
                    pass
            if check is False:
                tools.log('Adding Provider %s' % provider[1])
                database.add_provider(provider[1], provider[2], 'enabled', self.language, 'torrent')
                check = False

        for provider in providers[1]:
            check = False
            for kp in self.known_providers:
                if kp['country'] != self.language:
                    continue
                if kp['provider_type'] != 'hoster':
                    continue
                if provider[2] == kp['package'] and provider[1] == kp['provider_name']:
                    check = True
            if check is False:
                tools.log('Adding Provider %s' % provider[1])
                database.add_provider(provider[1], provider[2], 'enabled', self.language, 'hoster')
                check = False

        self.known_providers = database.get_providers()
Пример #6
0
    def update_known_providers(self):
        provider_types = ['torrent', 'hosters']
        sys.path.append(tools.dataPath)
        import providers

        providers = providers.get_all(self.language)

        if len(self.pre_update_collection) > 0:
            pack_name = self.pre_update_collection[0]['package']

            hosters = providers[1]
            torrent = providers[0]

            for provider_type in range(len(provider_types)):
                for i in providers[provider_type]:
                    provider_name = i[1]

                    # We need to check that the provider file exists after updating
                    # For some reason lsdir still shows files as existing after the module removes them.
                    path = os.path.join(self.providers_path, pack_name,
                                        self.language,
                                        provider_types[provider_type],
                                        provider_name + ".py")

                    if not os.path.exists(path):
                        continue

                    old_setting = [
                        x for x in self.pre_update_collection
                        if x['provider_type'] == provider_types[provider_type]
                        and x['package'] == pack_name
                        and x['provider_name'] == provider_name
                    ]

                    if len(old_setting) > 0:
                        old_setting = old_setting[0]
                        database.add_provider(old_setting['provider_name'],
                                              old_setting['package'],
                                              old_setting['status'],
                                              old_setting['country'],
                                              old_setting['provider_type'])
                    else:
                        database.add_provider(i[1], i[2], 'enabled',
                                              self.language,
                                              provider_types[provider_type])

        else:
            if self.known_providers is None or len(self.known_providers) == 0:

                for provider in providers[0]:
                    tools.log('Adding Provider %s' % provider[1])
                    database.add_provider(provider[1], provider[2], 'enabled',
                                          self.language, 'torrent')
                for provider in providers[1]:
                    tools.log('Adding Provider %s' % provider[1])
                    database.add_provider(provider[1], provider[2], 'enabled',
                                          self.language, 'hoster')

            else:

                for i in range(2):
                    for provider in providers[i]:
                        existing = [existing for existing in self.known_providers
                                    if provider[2] == existing['package']\
                                    and provider[1] == existing['provider_name']\
                                    and existing['provider_type'] == provider_types[i]]

                        if len(existing) == 0:
                            tools.log('Adding Provider %s' % provider[1])
                            database.add_provider(provider[1], provider[2],
                                                  'enabled', self.language,
                                                  provider_types[i])
                            check = False

        self.known_providers = database.get_providers()
    def update_known_providers(self):
        provider_types = ['torrent', 'hosters']
        sys.path.append(tools.dataPath)
        import providers

        all_providers = providers.get_all(self.language)
        all_providers = {'torrent': all_providers[0],
                         'hosters': all_providers[1]}

        database_providers = database.get_providers()

        for provider_type in provider_types:

            for provider in all_providers[provider_type]:
                database.add_provider(provider[1], provider[2], 'enabled', self.language,
                                      provider_type)

        # if len(self.pre_update_collection) > 0:
        #     pack_name = self.pre_update_collection[0]['package']
        #
        #     for provider_type in range(len(provider_types)):
        #         for i in providers[provider_type]:
        #             provider_name = i[1]
        #             tools.log(provider_name)
        #
        #             # We need to check that the provider file exists after updating
        #             # For some reason lsdir still shows files as existing after the module removes them.
        #             path = os.path.join(self.providers_path, pack_name, self.language,
        #                                 provider_types[provider_type], provider_name + ".py")
        #
        #             if not os.path.exists(path):
        #                 continue
        #
        #             old_setting = [x for x in self.pre_update_collection if
        #                            x['provider_type'] == provider_types[provider_type] and
        #                            x['package'] == pack_name and
        #                            x['provider_name'] == provider_name]
        #
        #             if len(old_setting) > 0:
        #                 old_setting = old_setting[0]
        #                 database.add_provider(old_setting['provider_name'],
        #                                       old_setting['package'],
        #                                       old_setting['status'],
        #                                       old_setting['country'],
        #                                       old_setting['provider_type'])
        #             else:
        #                 database.add_provider(i[1], i[2], 'enabled', self.language, provider_types[provider_type])
        #
        # else:
        #     if self.known_providers is None or len(self.known_providers) == 0:
        #
        #         for provider in providers[0]:
        #             tools.log('Adding Provider %s' % provider[1])
        #             database.add_provider(provider[1], provider[2], 'enabled', self.language, 'torrent')
        #         for provider in providers[1]:
        #             tools.log('Adding Provider %s' % provider[1])
        #             database.add_provider(provider[1], provider[2], 'enabled', self.language, 'hoster')
        #
        #     else:
        #
        #         for i in range(2):
        #             for provider in providers[i]:
        #                 existing = [existing for existing in self.known_providers
        #                             if provider[2] == existing['package']\
        #                             and provider[1] == existing['provider_name']\
        #                             and existing['provider_type'] == provider_types[i]]
        #
        #
        #                 if len(existing) == 0:
        #                     tools.log('Adding Provider %s' % provider[1])
        #                     database.add_provider(provider[1], provider[2], 'enabled', self.language,
        #                                           provider_types[i])
        #

        self.known_providers = database.get_providers()