Skip to main content

[mus]escore [d]own[l]oader, ported from TypeScript

Project description

musdl

logo

Code style: black PyPI - Downloads PyPI - License PyPI PyPI - Python Version Lines of code

NOTE

The author of musdl does NOT condone piracy in any way, and is not responsible for anything that happens as a result of piracy arising from the use of musdl.

musdl (musscore downloader) is a downloader for Musescore, written in Python. musdl can now only download scores as .mscz (use the Musescore software to export to other formats).

The easiest way to download the score is through the CLI:

musdl (musescore url)

To convert to another format, use -f/--format:

# export as midi
musdl -f mid (musescore url)

For a complete list of formats, run musdl --help. If you want to export in any format besides mscz, you need to install musescore first.

It can also be imported and used as a module:

from musdl import Score, OnlineScore

my_score = OnlineScore("musescore_url")

# Read the score's metadata,
name = my_score["workTitle"]
# or save the whole score...
my_score.export("mscz", "my_score.mscz")

# ...and then load it again.
my_score = Score.from_file("my_score.mscz")

How it works

I just copied over the IPNS-specific constants and used them to download the score file from Xmader's dataset.

Other approaches were considered:

  • Create a native Python interpreter just to decode the musescore js (like Js2py). (Will problably break with every API change.)
  • Use a headless JS browser with Selenium. (Resource-heavy, not really cross-platform.)
  • Run a JS engine like PyMiniRacer/PyQt5. (Better speed, but needs C extensions.)

So I decided to roll with the IPNS dataset.

takedown request, et tu

Take a look at this issue in the same repo.

Requirements

  • requests - Downloader.
  • beautifulsoup4 - Powerful HTML parser.

Hacking

All my python projects now use flit to build and publish. So you need to python3 -m pip install flit first.

flit build

Install

(python3 -m) pip install musdl

Optionally, to export the score in other formats (midi, mp3, etc.) install musescore. musdl relies on its command-line tool mscore to export scores:

# Linux
sudo (package manager/snap) install musescore
# Windows
scoop bucket add extras  # add the extras bucket if you haven't
scoop install musescore

License

MIT.

Changelog

3.1.0

Add export to other formats.

3.0.0

Complete re-write of musdl to use IPNS instead of relying on MuseScore's API, which can break anytime.

2.3.0

Better PDF page detection (now the exact number of pages are known at runtime). The attributes .user, .id, and .pages have been added to the Score class. (user and pages are self-explanatory, id is the score id.) Added support for multi-threaded downloading of PDF pages (specify with -t). Downloading (may) be faster.

2.2.2

Fixed PDF scaling issue on Windows.

2.2.1

Made PDF downloading a extra feature (because svglib and reportlab dependencies are not pure-Python).

2.2.0

Fixed PDF support for Windows. Now musdl uses svglib as the backend for adding SVGs to PDFs.

2.1.1-2.1.2

Added PDF support.

2.0.0

Added -O option to use the score's title as the output filename (y'know, like curl -O). Refactored code to be object-oriented, in the form of the Score class. This should make adding new features easier. (Plus, you can use musdl more programmatically!)

1.1.2

Version bump, use Flit to build instead of setup.py. Updated README too.

1.1.0

Added MusicXML download option, thanks to JPFrancoia for the update!

1.0.0

Initial version.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

musdl-3.1.0.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

musdl-3.1.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file musdl-3.1.0.tar.gz.

File metadata

  • Download URL: musdl-3.1.0.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for musdl-3.1.0.tar.gz
Algorithm Hash digest
SHA256 f916d7ad25d1603b8ea1203217ce190dc57f0c0d630aba95785d2bda0d685dc3
MD5 63e648c950fd395dcdf1564615625708
BLAKE2b-256 15363956a70adb41a170e7550f36ab2ae7d23b1533d8094bebb8689d566cf849

See more details on using hashes here.

File details

Details for the file musdl-3.1.0-py3-none-any.whl.

File metadata

  • Download URL: musdl-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for musdl-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23253afb5c38a82707e9a33059cc62988f32de2da3ad24b8ab9b27ff16349553
MD5 6672c4e9f6f7d92d4fe5b9d5b030e1bf
BLAKE2b-256 c400c66f9508895a66243799cc1c89a95588ade42bf990f68d003b3ae44635cc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page