Skip to content

Commit

Permalink
fix: undefined name 'traceback'
Browse files Browse the repository at this point in the history
  • Loading branch information
arzkar committed Jun 18, 2023
1 parent 9eea1f7 commit e1cf710
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions fichub_cli/utils/fichub.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry

import traceback
import re
import time
from colorama import Fore, Style
Expand Down Expand Up @@ -68,7 +68,7 @@ def get_fic_metadata(self, url: str, format_type: list):
logger.debug(
f"Headers: {response.request.headers}")
break
except (ConnectionError, TimeoutError, Exception) as e:
except (requests.exceptions.ConnectionError, requests.exceptions.Timeout) as e:
if self.debug:
logger.error(str(traceback.format_exc()))
tqdm.write("\n" + Fore.RED + str(e) + Style.RESET_ALL +
Expand All @@ -78,9 +78,9 @@ def get_fic_metadata(self, url: str, format_type: list):

try:
self.response = response.json()
self.file_format =[]
self.file_format = []
self.cache_hash = {}
cache_urls= {}
cache_urls = {}

for format in format_type:
if format == 0:
Expand All @@ -99,17 +99,17 @@ def get_fic_metadata(self, url: str, format_type: list):
self.file_format.append(".pdf")

elif format == 3:
cache_urls['zip'] =self.response['urls']['html']
cache_urls['zip'] = self.response['urls']['html']
self.cache_hash['zip'] = self.response['hashes']['epub']
self.file_format.append(".zip")

self.files = {}
self.files["meta"] = self.response['meta']
for file_format in self.file_format:
self.files[self.response['urls']['epub'].split(
"/")[4].split("?")[0].replace(".epub", file_format)] = {
"hash": self.cache_hash[file_format.replace(".","")],
"download_url": "https://fichub.net"+cache_urls[file_format.replace(".","")]
"/")[4].split("?")[0].replace(".epub", file_format)] = {
"hash": self.cache_hash[file_format.replace(".", "")],
"download_url": "https://fichub.net" + cache_urls[file_format.replace(".", "")]
}
# Error: 'epub_url'
# Reason: Unsupported URL
Expand Down Expand Up @@ -145,7 +145,7 @@ def get_fic_data(self, download_url: str):
logger.debug(
f"GET: {self.response_data.status_code}: {self.response_data.url}")
break
except (ConnectionError, TimeoutError, Exception) as e:
except (requests.exceptions.ConnectionError, requests.exceptions.Timeout) as e:
if self.debug:
logger.error(str(traceback.format_exc()))
tqdm.write("\n" + Fore.RED + str(e) + Style.RESET_ALL +
Expand Down

0 comments on commit e1cf710

Please sign in to comment.