Newer
Older
def download(self, song: Song):
if (Path(self.outdir) / f"{song.getFileName_Hash_TXT()}.txt").is_file() and self.cache:
with requests.Session() as s:
page = s.post(url, data={'wd': 1}, cookies={'PHPSESSID': self.sessid})
soup = BeautifulSoup(page.content, 'html.parser')
txt = soup.find(name="textarea").text
lines = []
for line in txt.split('\n'):
if line.strip() != "":
lines.append(line.replace("\r", ""))
txt = "\n".join(lines)
with open(Path(self.outdir) / f"{song.getFileName_Hash_TXT()}.txt", "w", encoding="utf-8") as f:
txt = self.txtparser.parse_file(str(file), encoding="utf-8")
txt.mp3 = str(file.with_suffix(".mp3").relative_to(file.parent))
txt.video = str(file.with_suffix(".mp4").relative_to(file.parent))
txt.cover = str(file.with_suffix(".jpg").relative_to(file.parent))
txt.songid = song.uri
txt.artist = song.artist_name
txt.title = song.track_name
if song.release_date != datetime.date.min:
txt.year = song.release_date