mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
fetch news: handle data: URLs
This commit is contained in:
parent
9e99606c64
commit
6c0edaf1d5
@ -17,6 +17,7 @@ import sys
|
|||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
from base64 import standard_b64decode
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
|
|
||||||
from calibre import browser, relpath, unicode_path
|
from calibre import browser, relpath, unicode_path
|
||||||
@ -248,13 +249,18 @@ class RecursiveFetcher:
|
|||||||
ans = response(q)
|
ans = response(q)
|
||||||
ans.newurl = url
|
ans.newurl = url
|
||||||
return ans
|
return ans
|
||||||
self.log.debug('Fetching', url)
|
|
||||||
st = time.monotonic()
|
st = time.monotonic()
|
||||||
|
|
||||||
|
is_data_url = url.startswith('data:')
|
||||||
|
if not is_data_url:
|
||||||
|
self.log.debug('Fetching', url)
|
||||||
# Check for a URL pointing to the local filesystem and special case it
|
# Check for a URL pointing to the local filesystem and special case it
|
||||||
# for efficiency and robustness. Bypasses delay checking as it does not
|
# for efficiency and robustness. Bypasses delay checking as it does not
|
||||||
# apply to local fetches. Ensures that unicode paths that are not
|
# apply to local fetches. Ensures that unicode paths that are not
|
||||||
# representable in the filesystem_encoding work.
|
# representable in the filesystem_encoding work.
|
||||||
|
if is_data_url:
|
||||||
|
payload = url.partition(',')[2]
|
||||||
|
return standard_b64decode(payload)
|
||||||
is_local = 0
|
is_local = 0
|
||||||
if url.startswith('file://'):
|
if url.startswith('file://'):
|
||||||
is_local = 7
|
is_local = 7
|
||||||
|
Loading…
x
Reference in New Issue
Block a user