Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metadata/Music: upgrade to unmodified CU LRC lyrics grabbers #847

Merged
merged 7 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions mythtv/programs/scripts/metadata/Music/lyrics/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# CU LRC files not needed in MythMusic:
addon.xml
default.py
README.txt
resources
lib/gui.py
lib/sync.py

# twitham's extra files not needed:
filetweak.py
30 changes: 15 additions & 15 deletions mythtv/programs/scripts/metadata/Music/lyrics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
#

set(PYFILES
azlyrics.py
darklyrics.py
embedlrc.py
filelyrics.py
genius.py
lrclib.py
lyricscom.py
lyricsify.py
lyricsmode.py
megalobiz.py
music163.py
musixmatch.py
musixmatchlrc.py
supermusic.py)
azlyrics.py
darklyrics.py
embedlrc.py
filelyrics.py
genius.py
lrclib.py
lyricscom.py
lyricsmode.py
megalobiz.py
music163.py
musixmatchlrc.py
musixmatch.py
rclyricsband.py
supermusic.py)

#
# The cmake documentation strongly recommands against globbing source file
Expand All @@ -42,6 +42,6 @@ add_custom_target(metadata_Music_lyrics ALL DEPENDS ${PROCESSED_FILES})
install(FILES README
DESTINATION ${CMAKE_INSTALL_DATADIR}/mythtv/metadata/Music/lyrics)
install(
DIRECTORY common examples
DIRECTORY common examples lib Kodistubs
DESTINATION ${CMAKE_INSTALL_DATADIR}/mythtv/metadata/Music/lyrics
PATTERN "\.gitignore" EXCLUDE)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This is a tiny portion of Kodistubs to translate CU LRC to MythTV.

If CU LRC ever refers to other functions, simply copy them in here
from original Kodistubs and update as needed.

[email protected], 2024/01 for v34

source: https://github.com/romanvm/Kodistubs
10 changes: 10 additions & 0 deletions mythtv/programs/scripts/metadata/Music/lyrics/Kodistubs/xbmc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Tiny portion of Kodistubs to translate CU LRC to MythTV. If CU LRC
# ever refers to other functions, simply copy them in here from
# original Kodistubs and update where needed like below.

import sys

LOGDEBUG = 0

def log(msg: str, level: int = LOGDEBUG) -> None:
print(msg, file=sys.stderr)
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Tiny portion of Kodistubs to translate CU LRC to MythTV. If CU LRC
# ever refers to other functions, simply copy them in here from
# original Kodistubs and update where needed like below.

from typing import Optional

class Addon:

def __init__(self, id: Optional[str] = None) -> None:
pass

def getLocalizedString(self, id: int) -> str:
# only testall.py / scrapertest.py needs only 1 message from
# resources/language/resource.language.en_us/strings.po
if (id == 32163):
return "Testing: %s"
return "(%s)" % id

def getSettingBool(self, id: str) -> bool:
return True

def getSettingInt(self, id: str) -> int:
return 0

def getSettingString(self, id: str) -> str:
return ""

def getAddonInfo(self, id: str) -> str:
return ""
38 changes: 38 additions & 0 deletions mythtv/programs/scripts/metadata/Music/lyrics/Kodistubs/xbmcgui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Tiny portion of Kodistubs to translate CU LRC to MythTV. If CU LRC
# ever refers to other functions, simply copy them in here from
# original Kodistubs and update where needed like below.

# show "dialog" on stderr for testall.py / scrapertest.py
import sys

class Dialog:

def __init__(self) -> None:
pass

def ok(self, heading: str, message: str) -> bool:
return True

class DialogProgress:

def __init__(self) -> None:
pass

def create(self, heading: str, message: str = "") -> None:
print("\tDIALOG created: ", heading, " : ", message, file=sys.stderr)
pass

def update(self, percent: int, message: str = "") -> None:
print("\tDIALOG updated %s: " % percent, message, file=sys.stderr)
pass

def close(self) -> None:
pass

def iscanceled(self) -> bool:
# not cancelled is needed to continue the testall.py / scrapertest.py
return False

class Window:
def __init__(self, existingWindowId: int = -1) -> None:
pass
56 changes: 56 additions & 0 deletions mythtv/programs/scripts/metadata/Music/lyrics/Kodistubs/xbmcvfs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Tiny portion of Kodistubs to translate CU LRC to MythTV. If CU LRC
# ever refers to other functions, simply copy them in here from
# original Kodistubs and update where needed like below.

from typing import Union, Optional
import os.path

# embedlrc.py and musixmatchlrc.py need some File access

class File:

def __init__(self, filepath: str, mode: Optional[str] = None) -> None:
self.filename = filepath
if mode:
self.fh = open(filepath, mode)
else:
self.fh = open(filepath, "rb")

def __enter__(self) -> 'File': # Required for context manager
return self

def __exit__(self, exc_type, exc_val, exc_tb): # Required for context manager
pass

def read(self, numBytes: int = 0) -> str:
if numBytes:
return self.fh.read(numBytes)
return self.fh.read()

def readBytes(self, numBytes: int = 0) -> bytearray:
if numBytes:
return bytearray(self.fh.read(numBytes))
return bytearray(self.fh.read())

def write(self, buffer: Union[str, bytes, bytearray]) -> bool:
return self.fh.write(buffer)

def size(self) -> int:
return 0

def seek(self, seekBytes: int, iWhence: int = 0) -> int:
return self.fh.seek(seekBytes, iWhence);

def tell(self) -> int:
return self.fh.tell()

def close(self) -> None:
self.fh.close()
pass

def exists(path: str) -> bool:
# for musixmatchlrc.py the test must work or return False
return os.path.isfile(path)

def translatePath(path: str) -> str:
return ""
Loading