MythTV master
filelyrics.py
Go to the documentation of this file.
1# -*- Mode: python; coding: utf-8; indent-tabs-mode: nil; -*-
2"""
3Scraper for file lyrics
4"""
5
6from lib.utils import *
7
8__title__ = "FileLyrics"
9__description__ = "Search the same directory as the track for lyrics"
10__author__ = "Paul Harrison"
11__version__ = "2.0"
12__priority__ = "90"
13__lrc__ = True
14
16 def __init__(self, *args, **kwargs):
17 self.DEBUG = kwargs['debug']
18 self.settings = kwargs['settings']
19
20 def get_lyrics(self, song):
21 log("%s: searching lyrics for %s - %s - %s" % (__title__, song.artist, song.album, song.title), debug=self.DEBUG)
22 lyrics = Lyrics(settings=self.settings)
23 lyrics.song = song
24 lyrics.source = __title__
25 lyrics.lrc = __lrc__
26
27 filename = song.filepath
28 filename = os.path.splitext(filename)[0]
29
30 # look for a file ending in .lrc with the same filename as the track minus the extension
31 lyricFile = filename + '.lrc'
32 log("%s: searching for lyrics file: %s " % (__title__, lyricFile), debug=self.DEBUG)
33 if os.path.exists(lyricFile) and os.path.isfile(lyricFile):
34 #load the text file
35 with open (lyricFile, "r") as f:
36 lines = f.readlines()
37
38 for line in lines:
39 lyrics.lyrics += line
40
41 return lyrics
42
43 return False
def __init__(self, *args, **kwargs)
Definition: filelyrics.py:16
None log(str msg, int level=LOGDEBUG)
Definition: xbmc.py:9