Compare commits
5 Commits
ca0e48a334
...
51042eefa9
Author | SHA1 | Date |
---|---|---|
7x11x13 | 51042eefa9 | |
7x11x13 | b7c0c448e7 | |
hunkyburrito | 2ee3b26ae4 | |
Littletsu | 3758fc194f | |
7x11x13 | c06f642bc1 |
|
@ -74,7 +74,7 @@ scdl me -f
|
||||||
even if track has a Downloadable file
|
even if track has a Downloadable file
|
||||||
--path [path] Use a custom path for downloaded files
|
--path [path] Use a custom path for downloaded files
|
||||||
--remove Remove any files not downloaded from execution
|
--remove Remove any files not downloaded from execution
|
||||||
--sync [file] Compare an archive file to a playlist and downloads/removes any changed tracks
|
--sync [file] Compare an archive file to a playlist and downloads/removes any changed tracks
|
||||||
--flac Convert original files to .flac
|
--flac Convert original files to .flac
|
||||||
--no-album-tag On some player track get the same cover art if from the same album, this prevent it
|
--no-album-tag On some player track get the same cover art if from the same album, this prevent it
|
||||||
--original-art Download original cover art
|
--original-art Download original cover art
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
# -*- encoding: utf-8 -*-
|
# -*- encoding: utf-8 -*-
|
||||||
"""Python Soundcloud Music Downloader."""
|
"""Python Soundcloud Music Downloader."""
|
||||||
__version__ = "v2.7.0"
|
__version__ = "v2.7.2"
|
||||||
|
|
84
scdl/scdl.py
84
scdl/scdl.py
|
@ -550,7 +550,10 @@ def download_original_file(client: SoundCloud, track: BasicTrack, title: str, pl
|
||||||
# Find filename
|
# Find filename
|
||||||
header = r.headers.get("content-disposition")
|
header = r.headers.get("content-disposition")
|
||||||
_, params = cgi.parse_header(header)
|
_, params = cgi.parse_header(header)
|
||||||
if "filename" in params:
|
if "filename*" in params:
|
||||||
|
encoding, filename = params["filename*"].split("''")
|
||||||
|
filename = urllib.parse.unquote(filename, encoding=encoding)
|
||||||
|
elif "filename" in params:
|
||||||
filename = urllib.parse.unquote(params["filename"], encoding="utf-8")
|
filename = urllib.parse.unquote(params["filename"], encoding="utf-8")
|
||||||
else:
|
else:
|
||||||
raise SoundCloudException(f"Could not get filename from content-disposition header: {header}")
|
raise SoundCloudException(f"Could not get filename from content-disposition header: {header}")
|
||||||
|
@ -732,6 +735,7 @@ def download_track(client: SoundCloud, track: BasicTrack, playlist_info=None, ex
|
||||||
filename.endswith(".mp3")
|
filename.endswith(".mp3")
|
||||||
or filename.endswith(".flac")
|
or filename.endswith(".flac")
|
||||||
or filename.endswith(".m4a")
|
or filename.endswith(".m4a")
|
||||||
|
or filename.endswith(".wav")
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
set_metadata(track, filename, playlist_info, **kwargs)
|
set_metadata(track, filename, playlist_info, **kwargs)
|
||||||
|
@ -880,52 +884,66 @@ def set_metadata(track: BasicTrack, filename: str, playlist_info=None, **kwargs)
|
||||||
track.artist = artist_title[0].strip()
|
track.artist = artist_title[0].strip()
|
||||||
track.title = artist_title[1].strip()
|
track.title = artist_title[1].strip()
|
||||||
break
|
break
|
||||||
|
mutagen_file = mutagen.File(filename)
|
||||||
audio = mutagen.File(filename, easy=True)
|
mutagen_file.delete()
|
||||||
audio.delete()
|
|
||||||
audio["title"] = track.title
|
|
||||||
audio["artist"] = track.artist
|
|
||||||
if track.genre:
|
|
||||||
audio["genre"] = track.genre
|
|
||||||
if track.permalink_url:
|
|
||||||
audio["website"] = track.permalink_url
|
|
||||||
if track.date:
|
|
||||||
audio["date"] = track.date
|
|
||||||
if playlist_info:
|
|
||||||
if not kwargs.get("no_album_tag"):
|
|
||||||
audio["album"] = playlist_info["title"]
|
|
||||||
audio["tracknumber"] = str(playlist_info["tracknumber"])
|
|
||||||
|
|
||||||
audio.save()
|
|
||||||
|
|
||||||
a = mutagen.File(filename)
|
|
||||||
if track.description:
|
if track.description:
|
||||||
if a.__class__ == mutagen.flac.FLAC:
|
if mutagen_file.__class__ == mutagen.flac.FLAC:
|
||||||
a["description"] = track.description
|
mutagen_file["description"] = track.description
|
||||||
elif a.__class__ == mutagen.mp3.MP3:
|
elif mutagen_file.__class__ == mutagen.mp3.MP3 or mutagen_file.__class__ == mutagen.wave.WAVE:
|
||||||
a["COMM"] = mutagen.id3.COMM(
|
mutagen_file["COMM"] = mutagen.id3.COMM(
|
||||||
encoding=3, lang="ENG", text=track.description
|
encoding=3, lang="ENG", text=track.description
|
||||||
)
|
)
|
||||||
elif a.__class__ == mutagen.mp4.MP4:
|
elif mutagen_file.__class__ == mutagen.mp4.MP4:
|
||||||
a["\xa9cmt"] = track.description
|
mutagen_file["\xa9cmt"] = track.description
|
||||||
if response:
|
if response:
|
||||||
if a.__class__ == mutagen.flac.FLAC:
|
if mutagen_file.__class__ == mutagen.flac.FLAC:
|
||||||
p = mutagen.flac.Picture()
|
p = mutagen.flac.Picture()
|
||||||
p.data = out_file.read()
|
p.data = out_file.read()
|
||||||
p.mime = "image/jpeg"
|
p.mime = "image/jpeg"
|
||||||
p.type = mutagen.id3.PictureType.COVER_FRONT
|
p.type = mutagen.id3.PictureType.COVER_FRONT
|
||||||
a.add_picture(p)
|
mutagen_file.add_picture(p)
|
||||||
elif a.__class__ == mutagen.mp3.MP3:
|
elif mutagen_file.__class__ == mutagen.mp3.MP3 or mutagen_file.__class__ == mutagen.wave.WAVE:
|
||||||
a["APIC"] = mutagen.id3.APIC(
|
mutagen_file["APIC"] = mutagen.id3.APIC(
|
||||||
encoding=3,
|
encoding=3,
|
||||||
mime="image/jpeg",
|
mime="image/jpeg",
|
||||||
type=3,
|
type=3,
|
||||||
desc="Cover",
|
desc="Cover",
|
||||||
data=out_file.read(),
|
data=out_file.read(),
|
||||||
)
|
)
|
||||||
elif a.__class__ == mutagen.mp4.MP4:
|
elif mutagen_file.__class__ == mutagen.mp4.MP4:
|
||||||
a["covr"] = [mutagen.mp4.MP4Cover(out_file.read())]
|
mutagen_file["covr"] = [mutagen.mp4.MP4Cover(out_file.read())]
|
||||||
a.save()
|
|
||||||
|
if mutagen_file.__class__ == mutagen.wave.WAVE:
|
||||||
|
mutagen_file["TIT2"] = mutagen.id3.TIT2(encoding=3, text=track.title)
|
||||||
|
mutagen_file["TPE1"] = mutagen.id3.TPE1(encoding=3, text=track.artist)
|
||||||
|
if track.genre:
|
||||||
|
mutagen_file["TCON"] = mutagen.id3.TCON(encoding=3, text=track.genre)
|
||||||
|
if track.permalink_url:
|
||||||
|
mutagen_file["WOAS"] = mutagen.id3.WOAS(url=track.permalink_url)
|
||||||
|
if track.date:
|
||||||
|
mutagen_file["TDAT"] = mutagen.id3.TDAT(encoding=3, text=track.date)
|
||||||
|
if playlist_info:
|
||||||
|
if not kwargs.get("no_album_tag"):
|
||||||
|
mutagen_file["TALB"] = mutagen.id3.TALB(encoding=3, text=playlist_info["title"])
|
||||||
|
mutagen_file["TRCK"] = mutagen.id3.TRCK(encoding=3, text=str(playlist_info["tracknumber"]))
|
||||||
|
mutagen_file.save()
|
||||||
|
else:
|
||||||
|
mutagen_file.save()
|
||||||
|
audio = mutagen.File(filename, easy=True)
|
||||||
|
audio["title"] = track.title
|
||||||
|
audio["artist"] = track.artist
|
||||||
|
if track.genre:
|
||||||
|
audio["genre"] = track.genre
|
||||||
|
if track.permalink_url:
|
||||||
|
audio["website"] = track.permalink_url
|
||||||
|
if track.date:
|
||||||
|
audio["date"] = track.date
|
||||||
|
if playlist_info:
|
||||||
|
if not kwargs.get("no_album_tag"):
|
||||||
|
audio["album"] = playlist_info["title"]
|
||||||
|
audio["tracknumber"] = str(playlist_info["tracknumber"])
|
||||||
|
|
||||||
|
audio.save()
|
||||||
|
|
||||||
def limit_filename_length(name: str, ext: str, max_bytes=255):
|
def limit_filename_length(name: str, ext: str, max_bytes=255):
|
||||||
while len(name.encode("utf-8")) + len(ext.encode("utf-8")) > max_bytes:
|
while len(name.encode("utf-8")) + len(ext.encode("utf-8")) > max_bytes:
|
||||||
|
|
Loading…
Reference in New Issue