Skip to content

Commit

Permalink
Merge pull request #7 from yogeshwaran01/v1.3-patch
Browse files Browse the repository at this point in the history
V1.3 patch
  • Loading branch information
yogeshwaran01 authored Aug 31, 2022
2 parents 3a92050 + 50d5d7e commit 11d5d9b
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10"]
python-version: ["3.8", 3.9, "3.10"]

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
disable=too-many-arguments
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
"python.formatting.blackPath": "~/.local/bin/black",
"python.formatting.autopep8Path": "~/.local/bin/autopep8",
"cSpell.words": [
"flet"
"addfinalizer",
"flet",
"lyricy",
"Megalobiz",
"pylrc",
"RCLYRICSBAND",
"pytest"
]
}
20 changes: 13 additions & 7 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

import flet
from flet import (
AlertDialog,
Expand Down Expand Up @@ -120,10 +122,14 @@ def build(self):
on_submit=lambda e: self.search_btn_clicked(e),
)

self.provider_query = RadioGroup(content=Row([
Radio(value='mo', label="Provider 1"),
Radio(value='rc', label="Provider 2")
]))
self.provider_query = RadioGroup(
content=Row(
[
Radio(value="mo", label="Provider 1"),
Radio(value="rc", label="Provider 2"),
]
)
)

self.results = Column()
self.action_btn = IconButton(icons.SEARCH, on_click=self.search_btn_clicked)
Expand Down Expand Up @@ -152,7 +158,9 @@ def search_btn_clicked(self, e):
self.update()
self.results.clean()
if self.provider_query.value == "rc":
results = Lyricy.search(self.search_query.value, provider=Providers.RCLYRICSBAND)
results = Lyricy.search(
self.search_query.value, provider=Providers.RCLYRICSBAND
)
else:
results = Lyricy.search(self.search_query.value)
for result in results:
Expand Down Expand Up @@ -181,7 +189,5 @@ def main(page: Page):
page.add(LyricyApp())


import os

port = int(os.environ.get("PORT", 5000))
flet.app(target=main, port=port)
10 changes: 5 additions & 5 deletions lyricy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"""

__package__ = "lyricy"
__description__ = (
"A command line lyrics utility tool which search and add lyrics to your offline songs"
)
__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"
__version__ = "1.3"
__author__ = "YOGESHWARAN R <[email protected]>"
__license__ = "MIT License"
__copyright__ = "Copyright 2022 Yogeshwaran R"


from enum import Enum
from typing import List

import music_tag

Expand Down Expand Up @@ -55,7 +55,7 @@ def add_to_track(self, path: str):

class Lyricy:
@staticmethod
def search(query: str, provider=Providers.MEGALOBIZ) -> list[Lyrics]:
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)
Expand Down
24 changes: 21 additions & 3 deletions lyricy/cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""cli script for download lyrics"""

import sys

import click
Expand All @@ -10,11 +12,13 @@

from .classes import BaseLyrics
from .providers import Megalobiz, RcLyricsBand
from . import __version__, __package__

console = Console()


def format_table(lyrics: BaseLyrics, disable_preview: bool) -> str:
"""render the table format for given lyrics"""
title = lyrics.title
sample_lyrics = lyrics.sample_lyrics
index = lyrics.index
Expand All @@ -24,6 +28,7 @@ def format_table(lyrics: BaseLyrics, disable_preview: bool) -> str:


def print_help_msg(command: callable):
"""Function print the help message on the console"""
with click.Context(command) as ctx:
click.echo(command.get_help(ctx))

Expand All @@ -35,11 +40,15 @@ def lyrics_without_tags(lyrics_with_lrc_tags: str) -> str:


@click.group()
@click.version_option(__version__, package_name=__package__)
def cli():
"""
A command line lyrics utility tool which search and add lyrics to your offline songs.
Web: https://lyricy.yogeshwaran01.repl.co/#/
GitHub: https://github.com/yogeshwaran01/lyricy
"""
pass


@click.command()
Expand All @@ -51,7 +60,14 @@ def cli():
@click.option("-s", "--save", help="Save file as .lrc")
@click.option("-q", "--query", type=str, help="search query of track name")
@click.option("-p", "--provider", type=str, help="Lyrics provider name [rc] or [mo]")
def search(track: str, query: str, disable_preview: bool, only_lyrics: bool, save: str, provider: str):
def search(
track: str,
query: str,
disable_preview: bool,
only_lyrics: bool,
save: str,
provider: str,
):
"""Search for lyrics for given track or query"""
if track:
f = music_tag.load_file(track)
Expand Down Expand Up @@ -105,7 +121,9 @@ def search(track: str, query: str, disable_preview: bool, only_lyrics: bool, sav
@click.option("--show", is_flag=True, help="Print the lyrics and ask for confirmation")
@click.option("--lrc", type=click.Path(exists=True), help="Lyrics file to add on track")
@click.option("-p", "--provider", type=str, help="Lyrics provider name [rc] or [mo]")
def add(track: str, show: bool, disable_preview: bool, lrc: str, query: str, provider: str):
def add(
track: str, show: bool, disable_preview: bool, lrc: str, query: str, provider: str
):
"""Search and add lyrics to given TRACK.
TRACK is the filepath of track.
Expand Down
15 changes: 10 additions & 5 deletions lyricy/providers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""lyrics providers"""

from typing import List
from urllib.parse import quote_plus

import requests
Expand All @@ -9,7 +12,8 @@
class Megalobiz:
"""Search and scrape lyrics for Megalobiz site"""

def search_lyrics(song_name: str) -> list[BaseLyrics]:
@staticmethod
def search_lyrics(song_name: str) -> List[BaseLyrics]:
"""Search for lyrics"""

results = []
Expand Down Expand Up @@ -43,9 +47,9 @@ def search_lyrics(song_name: str) -> list[BaseLyrics]:
)
]

else:
return results
return results

@staticmethod
def get_lyrics(link: str) -> str:
"""Scrape the lyrics for given track link"""

Expand All @@ -61,6 +65,7 @@ def get_lyrics(link: str) -> str:
class RcLyricsBand:
"""Search and scrape lyrics for RcLyricsBand site"""

@staticmethod
def search_lyrics(song_name: str):
"""Search for lyrics"""

Expand All @@ -85,9 +90,9 @@ def search_lyrics(song_name: str):
title=" No result found", link="", sample_lyrics="", index="1"
)
]
else:
return results
return results

@staticmethod
def get_lyrics(link: str):
"""Scrape the lyrics for given track link"""

Expand Down
25 changes: 10 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,24 @@
requirements = fh.read()

setup(
name='lyricy',
version='1.2',
author='Yogeshwaran R',
author_email='[email protected]',
description='A command line lyrics utitly tool which \
search and add lyrics to your offline songs.',
name="lyricy",
version="1.3",
author="Yogeshwaran R",
author_email="[email protected]",
description="A command line lyrics utility tool which \
search and add lyrics to your offline songs.",
long_description=long_description,
long_description_content_type="text/markdown",
license='MIT',
url='https://github.com/yogeshwaran01/lyricy',
license="MIT",
url="https://github.com/yogeshwaran01/lyricy",
download_url="https://github.com/yogeshwaran01/lyricy/archive/master.zip",
packages=find_packages(),
entry_points={
'console_scripts': [
'lyricy=lyricy.cli:cli'
]
},
entry_points={"console_scripts": ["lyricy=lyricy.cli:cli"]},
classifiers=(
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
),
keywords='python package lyrics lrc yogeshwaran01 songs',
keywords="python package lyrics lrc yogeshwaran01 songs",
install_requires=requirements,

)
5 changes: 5 additions & 0 deletions test/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TEST_QUERY_1 = "wasted"
FILE_PATH_1 = "wasted.lrc"

TEST_QUERY_2 = "beast mode"
FILE_PATH_2 = "beast_mode.lrc"
6 changes: 1 addition & 5 deletions test/test_lyricy.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
from lyricy import Lyricy, Lyrics, Providers

TEST_QUERY_1 = "karka karka"
FILE_PATH_1 = "karka_karka.lrc"

TEST_QUERY_2 = "beast mode"
FILE_PATH_2 = "beast_mode.lrc"
from test import TEST_QUERY_1, TEST_QUERY_2, FILE_PATH_1, FILE_PATH_2


def test_lyricy_megalobiz():
Expand Down

0 comments on commit 11d5d9b

Please sign in to comment.