Skip to content

Commit

Permalink
Merge pull request #4 from yogeshwaran01/lib-patch
Browse files Browse the repository at this point in the history
some updates
  • Loading branch information
yogeshwaran01 authored Jul 28, 2022
2 parents 363f49e + f2b03c6 commit db071d1
Show file tree
Hide file tree
Showing 8 changed files with 267 additions and 53 deletions.
145 changes: 120 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,46 @@
# 🎼 lyricy

A command line lyrics utility tool which search and add lyrics to your offline songs.
<!-- headings -->

<h1 align="center"> 🎼 lyricy </h1>

<p align="center">A command line lyrics utility tool which search and add lyrics to your offline songs.</p>

<!-- Badges -->

<p align="center">
<a href="https://pypi.org/project/lyricy/">
<img alt="PyPi" src="https://img.shields.io/pypi/v/lyricy.svg"/>
</a>
<a href="https://pepy.tech/project/lyricy">
<img alt="Downloads" src="https://pepy.tech/badge/lyricy"/>
</a>
<a href="https://github.com/yogeshwaran01/lyricy/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/yogeshwaran01/lyricy"></a>
<a href="https://github.com/yogeshwaran01/lyricy/network">
<img alt="GitHub forks" src="https://img.shields.io/github/forks/yogeshwaran01/lyricy"></a>
<a href="https://github.com/yogeshwaran01/lyricy/blob/master/LICENSE.txt">
<img alt="GitHub license" src="https://img.shields.io/github/license/yogeshwaran01/lyricy?color=blue"/>
</a>
<a href="https://github.com/psf/black">
<img alt="Code style" src="https://img.shields.io/badge/codestyle-Black-blue"/>
</a>
<img alt="GitHub Repo size" src="https://img.shields.io/github/repo-size/yogeshwaran01/lyricy"/>
<a href="https://github.com/yogeshwaran01/lyricy/actions/workflows/python-publish.yml">
<img alt="Upload lyricy to pypi" src="https://github.com/yogeshwaran01/lyricy/actions/workflows/python-publish.yml/badge.svg"/>
</a>
</p>

</hr>

## Why lyricy ?

We can use [spotDL/spotify-downloader](https://github.com/spotDL/spotify-downloader) to download our spotify playlist and songs along with album art and metadata. But it does not add the lyrics of the songs in song metadata. lyricy search for the lyrics of the song add to song metadata.

you can use [Retro music player](https://github.com/RetroMusicPlayer/RetroMusicPlayer) for andriod to listen the offlice local songs with synced lyrics.
you can use [Retro music player](https://github.com/RetroMusicPlayer/RetroMusicPlayer) for android to listen the offline local songs with synced lyrics.


## Lyrics Providers

- [https://www.megalobiz.com/](https://www.megalobiz.com/)
- [https://rclyricsband.com/](https://rclyricsband.com/)

## Installation

Expand All @@ -20,19 +54,26 @@ pip install lyricy

- Easy to add lyrics to your offline songs
- Preview of lyrics
- Synced lyrics with lru time tags
- Lyrics without lru tags
- Save lyrics as lru file
- Add your own lyrics or downloaed lyrics to songs
- Synced lyrics with lrc time tags
- Lyrics without lrc tags
- Save lyrics as lrc file
- Add your own lyrics or downloaded lyrics to songs
- Used as a python package

## Usage

- [Using as a CLI tool](#cli)
- [Using as a python package](#python-package)

### CLI

![demo](https://github.com/yogeshwaran01/lyricy/blob/master/demo/demo_lyricy.gif?raw=true)

```txt
Usage: lyricy [OPTIONS] COMMAND [ARGS]...
Usage: python -m lyricy [OPTIONS] COMMAND [ARGS]...
A CLI lyrics utility tool
A command line lyrics utility tool which search and add lyrics to your
offline songs.
Options:
--help Show this message and exit.
Expand All @@ -48,11 +89,12 @@ Commands:
- [Searching for lyrics for your track](#searching-for-lyrics-for-your-track)
- [Adding lyrics](#adding-lyrics)
- [Remove lyrics](#remove-lyrics)
- [Changing lyrics provider](#changing-lyrics-provider)
- [Show lyrics](#show-lyrics)
- [Downloading lrc file](#downloading-lrc-file)
- [Add lrc file to song](#add-lrc-file-to-song)

### Searching for lyrics using your queries
#### Searching for lyrics using your queries

```txt
Usage: python -m lyricy search [OPTIONS]
Expand All @@ -65,24 +107,25 @@ Options:
-l, --only-lyrics Show Lyrics Only (without LRC tag)
-s, --save TEXT Save file as .lrc
-q, --query TEXT search query of track name
--help Show this message and exit
-p, --provider TEXT Lyrics provider name [rc] or [mo]
--help Show this message and exit.
```

```bash
lyricy search --query "jolly yo gymkanna"
```

### Searching for lyrics for your track
#### Searching for lyrics for your track

Track must have ablum metameta `title`
Track must have album metadata `title`

```bash
lyricy search --track 'Imagine Dragons - Believer.mp3'
```

After searching it print list of lyrics, enter the index number lyrics to get the full lyrics

### Adding lyrics
#### Adding lyrics

Adding lyrics to track metadata to get synced lyrics

Expand All @@ -97,23 +140,39 @@ Options:
-q, --query TEXT search for this query instead of track name
-d, --disable-preview Disable the preview
--show Print the lyrics and ask for confirmation
--lru PATH Lyrics file to add on track
--lrc PATH Lyrics file to add on track
-p, --provider TEXT Lyrics provider name [rc] or [mo]
--help Show this message and exit.
```

```bash
lyricy add 'Imagine Dragons - Believer.mp3'
```

select the prefferd lyrics for the song to add it
select the preferred lyrics for the song to add it

If track does not have metadata `title` or any other unrevelant name, use can use `--query` option to override this.
If track does not have metadata `title` or any other irrelevant name, use can use `--query` option to override this.

```bash
lyricy add 'some-track.mp3' --query "vikram title track"
```

### Remove lyrics
#### Changing lyrics provider

By default the lyrics provider is is megalobiz, but you can use other provider is rclyricsband

- `rc` for [https://rclyricsband.com/](https://rclyricsband.com/)
- `mo` for [https://www.megalobiz.com/](https://www.megalobiz.com/)

```bash
lyricy add 'some-track.mp3' --query "vikram title track" --provider rc
```

```bash
lyricy search --query "karka kark" --provider mo
```

#### Remove lyrics

```txt
Usage: lyricy remove [OPTIONS] TRACK
Expand All @@ -130,7 +189,7 @@ Options:
lyricy remove 'Imagine Dragons - Believer.mp3'
```

### Show lyrics
#### Show lyrics

```txt
Usage: lyricy show [OPTIONS] TRACK
Expand All @@ -148,25 +207,61 @@ Options:
lyricy show 'Imagine Dragons - Believer.mp31
```
### Downloading lrc file
#### Downloading lrc file
```bash
lyricy search --query "new york" --save "new_york"
```
This search and ask for the prompt, select any song it will download and save as `lrc` file
### Add lrc file to song
#### Add lrc file to song
```bash
lyricy add track.mp3 --lru track.lru
lyricy add track.mp3 --lrc track.lrc
```
It will add the lyrics to song metadata
## Source of lyrics
### Python Package
#### Simple Usage
```python
>>> from lyricy import Lyricy
>>> l = Lyricy()
>>> results = l.search("karka karka")
>>> selected_lyrics = results[0]
>>> selected_lyrics.fetch()
>>> selected_lyrics.lyrics
>>> selected_lyrics.lyrics_without_lrc_tags
```
#### Saving and adding lyrics to track
All lyrics are scraped from [https://www.megalobiz.com/](https://www.megalobiz.com/)
```python
>>> selected_lyrics.save("lyrics.lrc")
>>> selected_lyrics.add_to_track("path_to_track.mp3")
```
#### Using Other Providers
Default provider is [https://www.megalobiz.com/](https://www.megalobiz.com/), but you can use other provider is [https://rclyricsband.com/](https://rclyricsband.com/).
```python
>>> from lyricy import Lyricy, Providers
>>> l = Lyricy()
>>> results = l.search("vikram", provider=Providers.RCLYRICSBAND)
>>> selected_lyrics = results[0]
>>> selected_lyrics.fetch()
>>> selected_lyrics.lyrics
>>> selected_lyrics.lyrics_without_lrc_tags
```
## Contributions
Expand Down
65 changes: 65 additions & 0 deletions lyricy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"""
lyricy
~~~~~~~~~~
A command line lyrics utility tool which search and add lyrics to your offline songs.
"""

__package__ = "lyricy"
__description__ = (
"A command line lyrics utility tool which search and add lyrics to your offline songs"
)
__url__ = "https://github.com/yogeshwaran01/lyricy"
__version__ = "1.2"
__author__ = "YOGESHWARAN R <[email protected]>"
__license__ = "MIT License"
__copyright__ = "Copyright 2022 Yogeshwaran R"


from enum import Enum

import music_tag

from .classes import BaseLyrics
from .cli import lyrics_without_tags
from .providers import Megalobiz, RcLyricsBand


class Providers(Enum):
MEGALOBIZ = Megalobiz
RCLYRICSBAND = RcLyricsBand


class Lyrics(BaseLyrics):
def fetch(self):
"""Fetch the full lyrics of the song with lrc tags"""
if "rclyricsband" in self.link:
self.lyrics = RcLyricsBand.get_lyrics(self.link)
else:
self.lyrics = Megalobiz.get_lyrics(self.link)
self.lyrics_without_lrc_tags = lyrics_without_tags(self.lyrics)

def save(self, path: str):
"""Save the lyrics file"""
with open(path, "w") as file:
file.write(self.lyrics)

def add_to_track(self, path: str):
"""
Add the lyrics to track metadata
`path`: path of the track
"""
f = music_tag.load_file(path)
f["lyrics"] = self.lyrics
f.save()


class Lyricy:
@staticmethod
def search(query: str, provider=Providers.MEGALOBIZ) -> list[Lyrics]:
"""Search for a lyrics for given Query"""
if provider == Providers.RCLYRICSBAND:
r = RcLyricsBand.search_lyrics(query)
return [Lyrics(**i.__dict__) for i in r]

r = Megalobiz.search_lyrics(query)
return [Lyrics(**i.__dict__) for i in r]
2 changes: 1 addition & 1 deletion lyricy/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


@dataclass
class Lyrics:
class BaseLyrics:
"""Dataclass Class for lyrics"""

title: str
Expand Down
Loading

0 comments on commit db071d1

Please sign in to comment.