Skip to content

Instantly share code, notes, and snippets.

Last active March 7, 2020 13:25
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save nosada/a4026b6920c417dc58522f8b493ece0f to your computer and use it in GitHub Desktop.
Download original size artwork from
#!/bin/env python
Usage: URL
URL URL of artwork in
from bs4 import BeautifulSoup
from docopt import docopt
import requests
from json import loads
from re import sub
def retrieve(url):
return requests.get(url).content
def parse(html):
soup = BeautifulSoup(html, features="html.parser")
source = sub(
r"^.*= ",
{"ng-controller": "ArtworkViewCtrl"}
thumbnails = loads(source)["ImageThumbnailsModel"][0]["Thumbnails"]
url = next(
thumbnail for thumbnail in thumbnails
if thumbnail["Name"].lower() == "original"
title, artist, _ = soup.find("title").text.split(" - ")
name = "{a}, {t}".format(a=artist, t=title)
return url, name
def download(url, name):
extension = url.split(".")[-1]
with open(".".join([name, extension]), "wb") as artwork:
if __name__ == "__main__":
ARGS = docopt(__doc__)
IMAGE_URL, IMAGE_NAME = parse(retrieve(URL))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment