fix: quote url

This commit is contained in:
relikd
2024-03-04 19:29:39 +01:00
parent d1f095ab59
commit 3ea186fb34

View File

@@ -212,9 +212,9 @@ class CacheDB:
return x.fetchone()[0] return x.fetchone()[0]
def getPendingQueue(self, *, done: int, batchsize: int) \ def getPendingQueue(self, *, done: int, batchsize: int) \
-> 'list[tuple[int, str]]': -> 'list[tuple[int, str, str]]':
x = self._db.execute('''SELECT idx.pk, # url || "/" || REPLACE(REPLACE(path_name, '#', '%23'), '?', '%3F')
url || "/" || REPLACE(REPLACE(path_name, '#', '%23'), '?', '%3F') x = self._db.execute('''SELECT idx.pk, url, path_name
FROM idx INNER JOIN urls ON urls.pk=base_url FROM idx INNER JOIN urls ON urls.pk=base_url
WHERE done=? LIMIT ?;''', [done, batchsize]) WHERE done=? LIMIT ?;''', [done, batchsize])
return x.fetchall() return x.fetchall()
@@ -359,12 +359,14 @@ def processPending():
if err_count > 0: if err_count > 0:
print() print()
print('URLs with Error:', err_count) print('URLs with Error:', err_count)
for uid, url in DB.getPendingQueue(done=3, batchsize=10): for uid, base, path_name in DB.getPendingQueue(done=3, batchsize=10):
print(f' - [{uid}] {url}') print(f' - [{uid}] {base}/{quote(path_name)}')
def procSinglePending(processed: int, pending: int, uid: int, url: str) \ def procSinglePending(
-> 'tuple[int, bool]': processed: int, pending: int, uid: int, base_url: str, path_name
) -> 'tuple[int, bool]':
url = base_url + '/' + quote(path_name)
humanUrl = url.split('archive.org/download/')[-1] humanUrl = url.split('archive.org/download/')[-1]
print(f'[{processed}|{pending} queued]: load[{uid}] {humanUrl}') print(f'[{processed}|{pending} queued]: load[{uid}] {humanUrl}')
try: try: