Уборка кода
This commit is contained in:
parent
4f2ae50ed0
commit
b693f882c5
1 changed files with 3 additions and 7 deletions
10
main.py
10
main.py
|
|
@ -1,23 +1,18 @@
|
||||||
#!/bin/python3
|
#!/bin/python3
|
||||||
import logging
|
import logging
|
||||||
import argparse
|
import argparse
|
||||||
import requests
|
|
||||||
import json
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import io
|
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import re
|
import re
|
||||||
import eyed3
|
import eyed3
|
||||||
from eyed3.id3.frames import ImageFrame
|
from eyed3.id3.frames import ImageFrame
|
||||||
import datetime
|
from typing import Optional
|
||||||
from typing import Optional, BinaryIO
|
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from requests import Session
|
from requests import Session
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import tempfile
|
|
||||||
|
|
||||||
MD5_SALT = 'XGRlBW9FXlekgbPrRHuSiA'
|
MD5_SALT = 'XGRlBW9FXlekgbPrRHuSiA'
|
||||||
ENCODED_BY = 'https://gitlab.com/llistochek/yandex-music-downloader'
|
ENCODED_BY = 'https://gitlab.com/llistochek/yandex-music-downloader'
|
||||||
|
|
@ -198,7 +193,7 @@ def prepare_track_path(directory: Path, path: Path, track: BasicTrackInfo) -> Pa
|
||||||
def set_id3_tags(path: Path, track: BasicTrackInfo, lyrics: Optional[str],
|
def set_id3_tags(path: Path, track: BasicTrackInfo, lyrics: Optional[str],
|
||||||
album_cover: Optional[bytes]) -> None:
|
album_cover: Optional[bytes]) -> None:
|
||||||
audiofile = eyed3.load(path)
|
audiofile = eyed3.load(path)
|
||||||
audiofile.tag = tag = eyed3.id3.tag.Tag(version=(2, 4, 0))
|
audiofile.tag = tag = eyed3.id3.tag.Tag()
|
||||||
tag.artist = '; '.join(track.artists)
|
tag.artist = '; '.join(track.artists)
|
||||||
tag.album_artist = track.album.artists[0]
|
tag.album_artist = track.album.artists[0]
|
||||||
tag.album = track.album.title
|
tag.album = track.album.title
|
||||||
|
|
@ -213,6 +208,7 @@ def set_id3_tags(path: Path, track: BasicTrackInfo, lyrics: Optional[str],
|
||||||
tag.lyrics.set(lyrics)
|
tag.lyrics.set(lyrics)
|
||||||
if album_cover is not None:
|
if album_cover is not None:
|
||||||
tag.images.set(ImageFrame.FRONT_COVER, album_cover, 'image/jpeg')
|
tag.images.set(ImageFrame.FRONT_COVER, album_cover, 'image/jpeg')
|
||||||
|
|
||||||
tag.save()
|
tag.save()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue