From: Stefan Huber Date: Wed, 15 Jan 2014 10:47:03 +0000 (+0100) Subject: processAdd: Be more pessimistic in parsing X-Git-Url: https://git.sthu.org/?a=commitdiff_plain;h=63d0b10b1aeeb8eebfbcd68be7cbea08c5ce03f3;p=dvrdb.git processAdd: Be more pessimistic in parsing --- diff --git a/dvr-db.py b/dvr-db.py index 1a2b5d3..3200118 100755 --- a/dvr-db.py +++ b/dvr-db.py @@ -182,13 +182,18 @@ def processAdd(db): bs = bs4.BeautifulSoup(htmldata) b = bs.body + id = None + #bs.body.find('form', attrs = {'id' : 'aspnetForm'}). - idattr = b.find('form').get('action') - idmatch = re.match(r'.*Id=([0-9]*).*', idattr) - if idmatch: - id = idmatch.group(1) - id = int(id) - else: + form = b.find('form') + if not form is None: + idattr = form.get('action') + if not idattr is None: + idmatch = re.match(r'.*Id=([0-9]*).*', idattr) + if idmatch: + id = idmatch.group(1) + id = int(id) + if id is None: print("Could not find ID.") return diff --git a/filldb.sh b/filldb.sh index a2be6c4..a231e8c 100755 --- a/filldb.sh +++ b/filldb.sh @@ -1,4 +1,6 @@ #!/bin/sh -find dump/ -name "*.gz" -exec sh -c "zcat {} | ./dvr-db.py -d all.sqlite -a" \; +rm -f failed.txt +rm -f all.sqlite +find dump/ -name "*.gz" -exec sh -c 'echo "Adding file {}"; zcat {} | ./dvr-db.py -d all.sqlite -a || echo {} >> failed.txt' \;