-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from yogeshwaran01/lib-patch
some updates
- Loading branch information
Showing
8 changed files
with
267 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
|
||
@dataclass | ||
class Lyrics: | ||
class BaseLyrics: | ||
"""Dataclass Class for lyrics""" | ||
|
||
title: str | ||
|
Oops, something went wrong.