Skip to main content

A Python module with a small cli, used to automatically download a Synthesia piano tutorial from a YouTube URL and convert it to a MIDI file.

Project description

youtube2midi

A Python module with a small cli, used to automatically download a Synthesia piano tutorial from a YouTube URL and convert it to a MIDI file. It uses youtube-dl and syn2midi.

Installation

youtube2midi can be installed from PyPi using pip

$ pip install youtube2midi

Or from source by cloning the repo and running the command

$ python setup.py install

Usage

Command line interface

The CLI has two possible entry points

$ youtube2midi

and

$ python -m youtube2midi

Example uses:

$ youtube2midi https://www.youtube.com/watch?v=0hhMl2W7F8U

$ youtube2midi https://www.youtube.com/watch?v=0hhMl2W7F8U -s 0:05 -e 3:35

$ youtube2midi https://www.youtube.com/watch?v=0hhMl2W7F8U -o rickroll.mid -m "path/to/my/custom/mask/file.bmp"

Some pre-made masks can be found in the package folder, syn2midi/mask.bmp and syn2midi/mask88.bmp

Command line reference:

youtube2midi [-h] [-o OUTPUT] [-m MASK] [-t TRANSPOSE] [-s START] [-e END] [-k] url

positional arguments:
  url                   URL to a Synthesia youtube video

optional arguments:
  -h, --help            show this help message and exit
  -o OUTPUT, --output OUTPUT
                        Name of output MIDI file
  -m MASK, --mask MASK  Path to a BMP image file to be used as mask. See https://github.com/minyor/syn2midi for details
  -t TRANSPOSE, --transpose TRANSPOSE
                        transpose notes shift, can be negative. 0 is default
  -s START, --start START
                        Start timestamp for video in the form mm:ss
  -e END, --end END     End timestamp for video in the form mm:ss
  -k, --keep-video      Keep the downloaded YouTube video instead of deleting it when done

Python module

The python module exposes a single function download_and_convert

>>> from youtube2midi import download_and_convert, MASK88
>>> download_and_convert('https://www.youtube.com/watch?v=0hhMl2W7F8U',
                        MASK88, output_name='rickroll.mid', start_time=5, end_time=3 * 60 + 35)

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

youtube2midi-0.1.1.post1.tar.gz (8.1 MB view details)

Uploaded Source

Built Distribution

youtube2midi-0.1.1.post1-py3-none-any.whl (8.1 MB view details)

Uploaded Python 3

File details

Details for the file youtube2midi-0.1.1.post1.tar.gz.

File metadata

  • Download URL: youtube2midi-0.1.1.post1.tar.gz
  • Upload date:
  • Size: 8.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for youtube2midi-0.1.1.post1.tar.gz
Algorithm Hash digest
SHA256 6f4a3838eabbf03f6fc932508e43a691f05f48fbb3c222892d9ea0b563d38c63
MD5 2dce4f471125b2b5a5ccc058cd619ecc
BLAKE2b-256 ef6bfcbe7e1ee0be53dc500f09a98a22408da5a652b4256100fcc0d1cddfa9b3

See more details on using hashes here.

File details

Details for the file youtube2midi-0.1.1.post1-py3-none-any.whl.

File metadata

  • Download URL: youtube2midi-0.1.1.post1-py3-none-any.whl
  • Upload date:
  • Size: 8.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for youtube2midi-0.1.1.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 6eb9c40373102a3cea53c9157ffce4e80bcc90bac641d52c8695b3945202c375
MD5 cfe2dbbbe422a5c2a9fa40e9cee958fe
BLAKE2b-256 7c56d8a5380705d4a2afab2cfa13315101511d6b3ab97f60ac5a530d764ada45

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