]> git.sthu.org Git - dvrdb.git/commitdiff
processAdd: Be more pessimistic in parsing
authorStefan Huber <shuber@sthu.org>
Wed, 15 Jan 2014 10:47:03 +0000 (11:47 +0100)
committerStefan Huber <shuber@sthu.org>
Wed, 15 Jan 2014 10:47:03 +0000 (11:47 +0100)
dvr-db.py
filldb.sh

index 1a2b5d3ec146e84092d6ad8b834dbd97bd91b471..320011832722c551faff7538c1dff3a46784dfa1 100755 (executable)
--- 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
 
index a2be6c4fd96b48f4b0c6e09f78b05e8cb3361557..a231e8c03e39e1c7d3289c09ec5a3c44182e23eb 100755 (executable)
--- 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' \;