Ejemplo n.º 1
0
 def __check_config(self, now):
     last_config_call = now - int(kodi.get_setting('%s-last-config' % (self.get_name())))
     if last_config_call > 8 * 60 * 60:
         url = urlparse.urljoin(self.base_url, CONFIG_URL)
         url += self.__get_extra(now)
         _html = super(GVCenter_Scraper, self)._cached_http_get(url, self.base_url, self.timeout, headers=HEADERS, cache_limit=8)
         kodi.set_setting('%s-last-config' % (self.get_name()), str(int(now)))
Ejemplo n.º 2
0
def update_all_scrapers():
        try: last_check = int(kodi.get_setting('last_list_check'))
        except: last_check = 0
        now = int(time.time())
        list_url = kodi.get_setting('scraper_url')
        scraper_password = kodi.get_setting('scraper_password')
        list_path = os.path.join(kodi.translate_path(kodi.get_profile()), 'scraper_list.txt')
        exists = os.path.exists(list_path)
        if list_url and scraper_password and (not exists or last_check < (now - (24 * 60 * 60))):
            scraper_list = utils2.get_and_decrypt(list_url, scraper_password)
            if scraper_list:
                try:
                    with open(list_path, 'w') as f:
                        f.write(scraper_list)
    
                    kodi.set_setting('last_list_check', str(now))
                    kodi.set_setting('scraper_last_update', time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(now)))
                    for line in scraper_list.split('\n'):
                        line = line.replace(' ', '')
                        if line:
                            scraper_url, filename = line.split(',')
                            if scraper_url.startswith('http'):
                                update_scraper(filename, scraper_url)
                except Exception as e:
                    log_utils.log('Exception during scraper update: %s' % (e), log_utils.LOGWARNING)
Ejemplo n.º 3
0
def update_all_scrapers():
    try:
        last_check = int(kodi.get_setting('last_list_check'))
    except:
        last_check = 0
    now = int(time.time())
    list_url = kodi.get_setting('scraper_url')
    scraper_password = kodi.get_setting('scraper_password')
    list_path = os.path.join(kodi.translate_path(kodi.get_profile()),
                             'scraper_list.txt')
    exists = os.path.exists(list_path)
    if list_url and scraper_password and (not exists or last_check <
                                          (now - (24 * 60 * 60))):
        scraper_list = utils2.get_and_decrypt(list_url, scraper_password)
        if scraper_list:
            try:
                with open(list_path, 'w') as f:
                    f.write(scraper_list)

                kodi.set_setting('last_list_check', str(now))
                kodi.set_setting(
                    'scraper_last_update',
                    time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(now)))
                for line in scraper_list.split('\n'):
                    line = line.replace(' ', '')
                    if line:
                        scraper_url, filename = line.split(',')
                        if scraper_url.startswith('http'):
                            update_scraper(filename, scraper_url)
            except Exception as e:
                log_utils.log('Exception during scraper update: %s' % (e),
                              log_utils.LOGWARNING)
Ejemplo n.º 4
0
 def __check_config(self, now):
     last_config_call = now - int(kodi.get_setting('%s-last-config' % (self.get_name())))
     if self.device_id is None or last_config_call > 8 * 60 * 60:
         self.device_id = ''.join(random.choice(string.digits) for _ in xrange(15))
         kodi.set_setting('%s-device_id' % (self.get_name()), self.device_id)
         url = urlparse.urljoin(self.base_url, CONFIG_URL)
         url += self.__get_extra(now)
         _html = super(GVCenter_Scraper, self)._cached_http_get(url, self.base_url, self.timeout, headers=HEADERS, cache_limit=8)
         kodi.set_setting('%s-last-config' % (self.get_name()), str(int(now)))
Ejemplo n.º 5
0
def get_ua():
    try: last_gen = int(kodi.get_setting('last_ua_create'))
    except: last_gen = 0
    if not kodi.get_setting('current_ua') or last_gen < (time.time() - (7 * 24 * 60 * 60)):
        index = random.randrange(len(RAND_UAS))
        user_agent = RAND_UAS[index].format(win_ver=random.choice(WIN_VERS), feature=random.choice(FEATURES), br_ver=random.choice(BR_VERS[index]))
        log_utils.log('Creating New User Agent: %s' % (user_agent), log_utils.LOGDEBUG)
        kodi.set_setting('current_ua', user_agent)
        kodi.set_setting('last_ua_create', str(int(time.time())))
    else:
        user_agent = kodi.get_setting('current_ua')
    return user_agent
Ejemplo n.º 6
0
def get_ua():
    try:
        last_gen = int(kodi.get_setting('last_ua_create'))
    except:
        last_gen = 0
    if not kodi.get_setting('current_ua') or last_gen < (time.time() -
                                                         (7 * 24 * 60 * 60)):
        index = random.randrange(len(RAND_UAS))
        user_agent = RAND_UAS[index].format(win_ver=random.choice(WIN_VERS),
                                            feature=random.choice(FEATURES),
                                            br_ver=random.choice(
                                                BR_VERS[index]))
        log_utils.log('Creating New User Agent: %s' % (user_agent),
                      log_utils.LOGDEBUG)
        kodi.set_setting('current_ua', user_agent)
        kodi.set_setting('last_ua_create', str(int(time.time())))
    else:
        user_agent = kodi.get_setting('current_ua')
    return user_agent
Ejemplo n.º 7
0
                match = re.search('(.*?)\s+\((\d{4})\)', match_title_year)
                if match:
                    match_title, match_year = match.groups()
                else:
                    match_title = match_title_year
                    match = re.search('class="video_quality".*?Year\s*(?:</b>)?\s*:\s*(\d{4})', result, re.DOTALL)
                    if match:
                        match_year = match.group(1)
                    else:
                        match_year = ''

                if not year or not match_year or year == match_year:
                    result = {'url': scraper_utils.pathify_url(url), 'title': match_title, 'year': match_year}
                    results.append(result)
        return results

    @classmethod
    def get_settings(cls):
        settings = super(cls, cls).get_settings()
        settings.append('         <setting id="%s-default_url" type="string" visible="false"/>' % (cls.get_name()))
        return settings

# if no default url has been set, then pick one and set it. If one has been set, use it
default_url = kodi.get_setting('%s-default_url' % (XMovies8_Scraper.get_name()))
if not default_url:
    BASE_URL = random.choice(['https://xmovies8.org', 'http://genvideos.com'])
    XMovies8_Scraper.base_url = BASE_URL
    kodi.set_setting('%s-default_url' % (XMovies8_Scraper.get_name()), BASE_URL)
else:
    XMovies8_Scraper.base_url = default_url
Ejemplo n.º 8
0
                        match_year = ''

                if not year or not match_year or year == match_year:
                    result = {
                        'url': self._pathify_url(url),
                        'title': match_title,
                        'year': match_year
                    }
                    results.append(result)
        return results

    @classmethod
    def get_settings(cls):
        settings = super(XMovies8_Scraper, cls).get_settings()
        settings.append(
            '         <setting id="%s-default_url" type="string" visible="false"/>'
            % (cls.get_name()))
        return settings


# if no default url has been set, then pick one and set it. If one has been set, use it
default_url = kodi.get_setting('%s-default_url' %
                               (XMovies8_Scraper.get_name()))
if not default_url:
    BASE_URL = random.choice(['https://xmovies8.org', 'http://genvideos.com'])
    XMovies8_Scraper.base_url = BASE_URL
    kodi.set_setting('%s-default_url' % (XMovies8_Scraper.get_name()),
                     BASE_URL)
else:
    XMovies8_Scraper.base_url = default_url