Merge pull request #819 from Gluejar/dropboxct

Dropbox contenttype
pull/94/head
eshellman 2018-12-10 14:52:27 -05:00 committed by GitHub
commit 02ec8af4c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -446,11 +446,12 @@ def type_for_url(url, content_type=None):
if Ebook.objects.filter(url=url):
return Ebook.objects.filter(url=url)[0].format
ct = content_type if content_type else contenttyper.calc_type(url)
binary_type = re.search("octet-stream", ct) or re.search("application/binary", ct)
if re.search("pdf", ct):
return "pdf"
elif re.search("octet-stream", ct) and re.search("pdf", url, flags=re.I):
elif binary_type and re.search("pdf", url, flags=re.I):
return "pdf"
elif re.search("octet-stream", ct) and re.search("epub", url, flags=re.I):
elif binary_type and re.search("epub", url, flags=re.I):
return "epub"
elif re.search("text/plain", ct):
return "text"

View File

@ -18,7 +18,9 @@ class Command(BaseCommand):
new_ebf, new = dl_online(online)
if new_ebf and new:
done += 1
if done > limit:
if done == limit or done == 50:
break
self.stdout.write('harvested {} ebooks'.format(done))
if done == 50:
self.stdout.write('50 is the maximum; repeat to do more')