refactor find_links.py by adding methods for specific tasks
This commit is contained in:
@@ -25,9 +25,9 @@ class MediaFile(Base, BaseMixin, BaseVideoMixin):
|
||||
def update_title(self) -> None:
|
||||
logging.info(f"update title for {self.url}")
|
||||
try:
|
||||
r = requests.get(self.url)
|
||||
r = requests.get(str(self.url))
|
||||
soup = BeautifulSoup(r.content, "html.parser")
|
||||
title = soup.title.string
|
||||
title = soup.title.get_text() # type: ignore
|
||||
self.title = title
|
||||
self.review = False
|
||||
except:
|
||||
@@ -37,7 +37,7 @@ class MediaFile(Base, BaseMixin, BaseVideoMixin):
|
||||
|
||||
def download_file(self, download_dir: str, dl_tool: str):
|
||||
logging.info(f"download file for {self.url} to {download_dir}")
|
||||
result = subprocess.run([dl_tool, self.url], cwd=download_dir, capture_output=True, text=True)
|
||||
result = subprocess.run([dl_tool, self.url], cwd=download_dir, capture_output=True, text=True) # type: ignore
|
||||
if result.returncode == 0:
|
||||
output = result.stdout
|
||||
output = re.sub(' +', ' ', output)
|
||||
|
||||
Reference in New Issue
Block a user