def __init__(self, download_dir='downloads/', lyrics=True, cover=True): self.ms = MusicSource() config.init() self.song_list = [] self.change_dl_dir(download_dir) config.set('lyrics', bool(lyrics)) config.set('cover', bool(cover))
def test_set(): config.init() assert config.get("fasdfjklasd") == "" config.set("fasdfjklasd", "music-dl") assert config.get("fasdfjklasd") == "music-dl" proxies = {"http": "http://127.0.0.1:1087", "https": "http://127.0.0.1:1087"} config.set("proxies", proxies) assert config.get("proxies")["http"] == "http://127.0.0.1:1087" assert config.get("proxies")["https"] == "http://127.0.0.1:1087"
def test_music_list_merge(): config.init() m1 = Music() m1.size, m1.title, m1.singer = 4.3, "七里香", "周杰伦" m2 = Music() m2.size, m2.title, m2.singer = 5.3, "告白气球", "周杰伦" m3 = Music() m3.size, m3.title, m3.singer = 10.51, "告白气球", "周杰伦" m4 = Music() m4.size, m4.title, m4.singer = 4.5, "告白气球", "李狗蛋" music_list = core.music_list_merge([m1, m2, m3, m4]) assert len(music_list) == 3 assert music_list[0] == m4 assert music_list[1] == m3 assert music_list[2] == m1
def test_playlist(): config.init() config.set('outdir', 'E:\\My Documents\\My Musics\\') # config.set('outdir', 'E:\\test\\') config.set('lyrics', True) # config.set('lyricsOnly', True) config.set('source', 'netease') config.set('playlist', 'https://music.163.com/playlist?id=4943411818&userid=52794579') ms = MusicSource() songs_list = ms.playlist(config.get("playlist")) for idx in songs_list: idx.download() assert songs_list is not None
def test_get(): config.init() assert config.get("number") == 5 assert config.get("outdir") == "." assert config.get("fasdfjklasd") == ""
def test_init(): # with pytest.raises(AttributeError): # config.opts config.init() assert config.opts
from os import path from music_dl import config config.init() from music_dl.addons.netease import netease_single from lib.music.music_api import get_lyric, get_cover from lib.music.musictag import ID3Tags import argparse def download(url, output): config.set("cover", False) config.set("lyrics", False) config.set("verbose", True) config.set("outdir", output) song = netease_single(url) song.download() file = path.join(output, song.song_fullname) tag = ID3Tags(file) tag.title = song.title tag.album = song.album tag.artist = song.singer tag.url = url