This commit is contained in:
j 2019-08-05 12:19:24 +02:00
parent a131c78482
commit ee9e430ef8
2 changed files with 12 additions and 5 deletions

View file

@ -136,7 +136,7 @@ def parse_cast(string):
results[rkey] = cast[key].split(', \n')
return results
def update_ids(year, month=None, day=None, sort=None, expexted=None):
def update_ids(year, month=None, day=None, sort=None, expected=None):
films = {}
if day is not None:
url = get_day(year, month, day)
@ -155,8 +155,8 @@ def update_ids(year, month=None, day=None, sort=None, expexted=None):
else:
urls = [url]
if not expexted:
expexted = get_film_count(year, month, day)
if not expected:
expected = get_film_count(year, month, day)
for url in urls:
data = read_url(url, timeout=TIMEOUT)
@ -171,7 +171,7 @@ def update_ids(year, month=None, day=None, sort=None, expexted=None):
has_after = re.compile(after_link).findall(data)
if has_next:
n = '%s&start=%s' % (url, start)
elif sort != 'alpha' and start > MAX_PER_RANGE and has_after:
elif sort != 'alpha' and has_after:
n = '%s%s' % (base_url, has_after[0])
else:
n = False
@ -246,7 +246,7 @@ def update_ids(year, month=None, day=None, sort=None, expexted=None):
json.dump(films, fd, indent=4, ensure_ascii=False, sort_keys=True)
r = len(films)
if r != expected:
print('%s: got %s, expected %s' % (key, r, expexted))
print('%s: got %s, expected %s' % (key, r, expected))
return r
def save_film_counts(film_counts):

View file

@ -3,6 +3,7 @@
from django.core.management.base import BaseCommand
import movie.models
import movie.imdbids
class Command(BaseCommand):
"""
@ -11,6 +12,12 @@ class Command(BaseCommand):
help = 'load ids from sites that dont support search.'
args = ''
def add_arguments(self, parser):
parser.add_argument('--debug', action='store_true', dest='debug', default=False, help='print debug info')
def handle(self, **options):
timeout = 30*24*60*60
if options.get('debug'):
movie.imdbids.DEBUG = True
movie.models.get_new_ids(timeout)