abhimanyuPathania / lyrico

A python based command-line lyrics downloader
https://pypi.python.org/pypi/lyrico
Other
15 stars 6 forks source link

lyrico

lyrico is a command line application which downloads lyrics for your songs. When given a folder, lyrico will:

Current version of lyrico supports only unsynced lyrics.

Support

Installation

Use the standard pip install::

pip install lyrico

This will also install the dependencies. Hence, it is recommended to install lyrico on a separate virtual environment <https://pypi.python.org/pypi/virtualenv>_.

You can test if lyrico was installed correctly by running the 'lyrico' command, which now should be available::

lyrico

This would give the following output::

source_dir is not set. Please use the "set" command to set source_dir.
use "lyrico --help" to view commands.
Your current settings:

ACTIONS
    save_to_file = True
    save_to_tag = False
    overwrite = False

PATHS
    source_dir = None
    lyrics_dir = None

SOURCES
    lyric_wikia = True
    lyrics_n_music = True
    musix_match = True
    lyricsmode = True
    az_lyrics = False

If you get this screen, that means lyrico and its dependencies were installed correctly.

If you see an error like ImportError: No module named mutagen.id3, this means that the dependencies were not installed for some reason. In that case you can install them very easily with single command. Here's what you do:

  1. Go to lyrico's GitHub page <https://github.com/abhimanyuPathania/lyrico>_.
  2. Download repository as ZIP and extract the requirements.txt file from it. It is in the root directory of repository. This is the only file you need.
  3. Open command prompt in directory containing the requirements.txt and run following command (if you're using a virtual environment, activate it before running the command)::

    pip install -r requirements.txt

    This will install all of the lyrico's dependencies and now you can try testing with the 'lyrico' command. It should give no errors.

Running lyrico

lyrico operates using two directories (folders):

Before running lyrico you must set these using the set command. Values must be absolute paths to the directories. Once set, lyrico will remember your settings (which can be changed easily at any time). So this has to be done only for the first time.

This is how an example first-run would look like on Windows.

  1. Set the source_dir::

    lyrico set source_dir D:\test\Music

    This logs the following message::

    source_dir updated. lyrico will scan the following folder for audio files: D:\test\Music

    When setting source_dir, the directory must exist beforehand. lyrico will not create the source_dir for you.

  2. Set the lyrics_dir::

    lyrico set lyrics_dir D:\test\Lyrics

    This logs the following in command prompt::

    Directory does not exist. Creating new one. lyrics_dir updated. lyrico will save lyrics files in the following folder: D:\test\Lyrics

    Unlike source_dir, when setting the lyrics_dir to folder that does not exist (as in this example); lyrico will create it for you.

  3. Run lyrico::

    lyrico

    This will start the application and it will start downloading the lyrics for songs that it detects in the source_dir. You will be able to see the status (song name, lyrics URL) in the command prompt as it downloads, one at a time, the lyrics for each song.

    Finally it builds the log of whole operation and saves it in the log.txt file. log.txt is located in your lyrics_dir.

Other Settings and Commands

Basic settings like source_dir and lyrics_dir can be repeatedly changed using the set command as described in the example above. There are few more settings that are available to control lyrico's actions. These actions can be either disabled or enabled.

The above three settings can be changed using enable and disable commands. This is how you will enable save_to_tag from its default 'disabled' setting::

lyrico enable save_to_tag

This would log::

save_to_tag enabled
lyrico will embed the downloaded lyrics into song tags.

Similarly to disable save_to_file::

lyrico disable save_to_file

This gives following message in command prompt::

save_to_file disabled
lyrico will not save the downloaded lyrics to text files.

Lyrics Sources

lyrico uses the following sources from where it downloads the lyrics:

  1. Lyric Wikia <http://lyrics.wikia.com/wiki/Lyrics_Wiki>_ : lyric_wikia

  2. LYRICSnMUSIC <http://www.lyricsnmusic.com/>_ : lyrics_n_music

  3. musiXmatch <https://www.musixmatch.com/>_ : musix_match

  4. LYRICSMODE <http://www.lyricsmode.com/>_ : lyricsmode

  5. AZLyrics <http://www.azlyrics.com/>_ : az_lyrics (disabled by default)

The search order is same as enumerated above and cannot be changed. You can, however, disable or enable any of the sources using the same enable and disable commands. When a source is disabled, it is simply skipped during the search.

For example, to enable AZLyrics::

lyrico enable az_lyrics

Use the command line name for the source, which is mentioned after the link to the source in the above list. This logs the following message indicating that az_lyrics will be used as a source::

az_lyrics enabled
lyrico will use AZLyrics as a source for lyrics.

Or to disable Lyric Wikia::

lyrico disable lyric_wikia:

This logs the following message::

lyric_wikia disabled
lyrico will not use Lyric Wikia as a source for lyrics.

Audio Formats and Tags

Below is the table of supported audio formats and their supported tags:

+--------------------------------------------+----------------------------------------------+ | Audio Format | Tag | +============================================+==============================================+ | mp3 | ID3 Tags | +--------------------------------------------+----------------------------------------------+ | flac | Vorbis Comments | +--------------------------------------------+----------------------------------------------+ | m4a, mp4 | MP4 Tags (iTunes metadata) | +--------------------------------------------+----------------------------------------------+ | wma | ASF | +--------------------------------------------+----------------------------------------------+ | ogg, oga | Vorbis Comments | +--------------------------------------------+----------------------------------------------+

lyrico goodness

Here are somethings that lyrico does well:

lyrico gotchas

Here are few points you should know before using lyrico:

Dependencies

lyrico uses and thanks the following python packages:

A note on mass downloading

Since lyrico is simply scraping lyrics off the HTML pages of the sources, please don't set source_dir to a folder having thousands of songs.

They might ban your bot. az_lyrics sometimes bans your IP (not sure if permanent) if you hit them with too many failed requests. Though, refreshing your IP by restarting your router or using a VPN solves that. Hence, az_lyrics as a source is disabled by default. Only use it if you are looking for recent lyrics.

Also, downloading 1000s of lyrics will be slow since lyrico does not batch-download. It sends one request to one source at a time. This is by design.

I personally use it at one or two albums at time and keep checking for any errors in log.txt.

Changelog