Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package osdlyrics for openSUSE:Factory checked in at 2021-11-22 23:04:33 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/osdlyrics (Old) and /work/SRC/openSUSE:Factory/.osdlyrics.new.1895 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "osdlyrics" Mon Nov 22 23:04:33 2021 rev:6 rq:933131 version:0.5.7 Changes: -------- --- /work/SRC/openSUSE:Factory/osdlyrics/osdlyrics.changes 2021-10-26 20:14:35.754038399 +0200 +++ /work/SRC/openSUSE:Factory/.osdlyrics.new.1895/osdlyrics.changes 2021-11-22 23:05:28.665671568 +0100 @@ -1,0 +2,10 @@ +Mon Nov 22 13:14:40 UTC 2021 - Hillwood Yang <[email protected]> + +- Update version to 0.5.7 + * Netease: Show more results + * Add Megalobiz + * Remove ViewLyrics + * Remove LRC123 + * Add Subtitles4Songs + +------------------------------------------------------------------- Old: ---- osdlyrics-0.5.5.tar.gz New: ---- osdlyrics-0.5.7.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ osdlyrics.spec ++++++ --- /var/tmp/diff_new_pack.pWCBTV/_old 2021-11-22 23:05:29.197669783 +0100 +++ /var/tmp/diff_new_pack.pWCBTV/_new 2021-11-22 23:05:29.197669783 +0100 @@ -17,7 +17,7 @@ Name: osdlyrics -Version: 0.5.5 +Version: 0.5.7 Release: 0 Summary: A third-party lyrics display program License: GPL-3.0-or-later ++++++ osdlyrics-0.5.5.tar.gz -> osdlyrics-0.5.7.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.5/.github/workflows/ci.yml new/osdlyrics-0.5.7/.github/workflows/ci.yml --- old/osdlyrics-0.5.5/.github/workflows/ci.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/osdlyrics-0.5.7/.github/workflows/ci.yml 2021-05-24 23:50:17.000000000 +0200 @@ -0,0 +1,27 @@ +name: CI +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +jobs: + build: + runs-on: ubuntu-latest + if: github.event.pull_request.draft == false + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: Install dependencies + run: sudo apt-get install dh-python intltool lib{dbus-glib-1,gtk2.0,notify,x11}-dev python3{,-dbus,-future,-gi} + + - name: Autogen + run: ./autogen.sh + + - name: Configure + run: ./configure --prefix=/usr PYTHON=/usr/bin/python3 + + - name: Make + run: make diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.5/configure.ac new/osdlyrics-0.5.7/configure.ac --- old/osdlyrics-0.5.5/configure.ac 2021-05-19 14:09:33.000000000 +0200 +++ new/osdlyrics-0.5.7/configure.ac 2021-05-24 23:50:17.000000000 +0200 @@ -164,9 +164,9 @@ python/dbusext/Makefile lyricsources/Makefile lyricsources/xiami/Makefile - lyricsources/lrc123/Makefile - lyricsources/viewlyrics/Makefile + lyricsources/megalobiz/Makefile lyricsources/netease/Makefile + lyricsources/subtitles4songs/Makefile tools/Makefile ]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.5/lyricsources/Makefile.am new/osdlyrics-0.5.7/lyricsources/Makefile.am --- old/osdlyrics-0.5.5/lyricsources/Makefile.am 2021-05-19 14:09:33.000000000 +0200 +++ new/osdlyrics-0.5.7/lyricsources/Makefile.am 2021-05-24 23:50:17.000000000 +0200 @@ -1 +1 @@ -SUBDIRS = xiami lrc123 viewlyrics netease +SUBDIRS = xiami megalobiz netease subtitles4songs diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.5/lyricsources/lrc123/Makefile.am new/osdlyrics-0.5.7/lyricsources/lrc123/Makefile.am --- old/osdlyrics-0.5.5/lyricsources/lrc123/Makefile.am 2021-05-19 14:09:33.000000000 +0200 +++ new/osdlyrics-0.5.7/lyricsources/lrc123/Makefile.am 1970-01-01 01:00:00.000000000 +0100 @@ -1,19 +0,0 @@ -lrc123_PYTHON = lrc123.py - -lrc123dir = $(pkglibdir)/lyricsources/lrc123 - - -servicedir = $(datadir)/dbus-1/services -service_in_files = org.osdlyrics.LyricSourcePlugin.lrc123.service.in -service_DATA = $(service_in_files:.service.in=.service) - -EXTRA_DIST = \ - $(service_in_files) \ - $(NULL) - -$(service_DATA): $(service_in_files) - @sed -e "s|\@pkglibdir\@|$(pkglibdir)|" -e "s|\@PYTHON\@|$(PYTHON)|" $< > $@ - -CLEANFILES = \ - org.osdlyrics.LyricSourcePlugin.lrc123.service \ - $(NULL) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.5/lyricsources/lrc123/lrc123.py new/osdlyrics-0.5.7/lyricsources/lrc123/lrc123.py --- old/osdlyrics-0.5.5/lyricsources/lrc123/lrc123.py 2021-05-19 14:09:33.000000000 +0200 +++ new/osdlyrics-0.5.7/lyricsources/lrc123/lrc123.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,94 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2012 Tiger Soldier <[email protected]> -# -# This file is part of OSD Lyrics. -# -# OSD Lyrics is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OSD Lyrics is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with OSD Lyrics. If not, see <https://www.gnu.org/licenses/>. -# - -from builtins import super -from future import standard_library -standard_library.install_aliases() - -import http.client -import logging -import re - -import pycurl - -from osdlyrics.lyricsource import BaseLyricSourcePlugin, SearchResult -from osdlyrics.utils import get_proxy_settings, http_download - -HOST = 'www.lrc123.com' -SEARCH_URL = '/?keyword=%s&field=all' -RESULT_PATTERN = re.compile(r'<div class="newscont .*?href="/\?field=singer.*?>(.*?)</a>.*?href="/\?field=album.*?>(.*?)</a>.*?href="/\?field=song.*?>(.*?)</a>.*?href="/download/lrc/(.*?)">LRC', re.DOTALL) -DOWNLOAD_URL_PREFIX = '/download/lrc/' - - -class Lrc123Source(BaseLyricSourcePlugin): - """ Lyric source from xiami.com - """ - - def __init__(self): - super().__init__(id='lrc123', name='LRC123') - - def do_search(self, metadata): - # type: (osdlyrics.metadata.Metadata) -> List[SearchResult] - keys = [] - if metadata.title: - keys.append(metadata.title) - if metadata.artist: - keys.append(metadata.artist) - urlkey = (' '.join(keys)) - params = {'keyword': urlkey, - 'field': 'all'} - try: - status, content = http_download( - url=HOST + '/', - params=params, - proxy=get_proxy_settings(config=self.config_proxy)) - except pycurl.error as e: - logging.error('Download failed. %s', e.args[1]) - return [] - - if status < 200 or status >= 400: - raise http.client.HTTPException(status) - match = RESULT_PATTERN.findall(content) - result = [] - if match: - for artist, album, title, url in match: - title = title.replace('<span class="highlighter">', '').replace('</span>', '') - artist = artist.replace('<span class="highlighter">', '').replace('</span>', '') - album = album.replace('<span class="highlighter">', '').replace('</span>', '') - url = DOWNLOAD_URL_PREFIX + url - result.append(SearchResult(title=title, - artist=artist, - album=album, - sourceid=self.id, - downloadinfo=url)) - return result - - def do_download(self, downloadinfo): - # type: (Any) -> bytes - status, content = http_download(url=HOST + downloadinfo, - proxy=get_proxy_settings(self.config_proxy)) - if status < 200 or status >= 400: - raise http.client.HTTPException(status, '') - return content - - -if __name__ == '__main__': - lrc123 = Lrc123Source() - lrc123._app.run() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.5/lyricsources/lrc123/org.osdlyrics.LyricSourcePlugin.lrc123.service.in new/osdlyrics-0.5.7/lyricsources/lrc123/org.osdlyrics.LyricSourcePlugin.lrc123.service.in --- old/osdlyrics-0.5.5/lyricsources/lrc123/org.osdlyrics.LyricSourcePlugin.lrc123.service.in 2021-05-19 14:09:33.000000000 +0200 +++ new/osdlyrics-0.5.7/lyricsources/lrc123/org.osdlyrics.LyricSourcePlugin.lrc123.service.in 1970-01-01 01:00:00.000000000 +0100 @@ -1,3 +0,0 @@ -[D-BUS Service] -Name=org.osdlyrics.LyricSourcePlugin.lrc123 -Exec=@PYTHON@ @pkglibdir@/lyricsources/lrc123/lrc123.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.5/lyricsources/megalobiz/Makefile.am new/osdlyrics-0.5.7/lyricsources/megalobiz/Makefile.am --- old/osdlyrics-0.5.5/lyricsources/megalobiz/Makefile.am 1970-01-01 01:00:00.000000000 +0100 +++ new/osdlyrics-0.5.7/lyricsources/megalobiz/Makefile.am 2021-05-24 23:50:17.000000000 +0200 @@ -0,0 +1,19 @@ +megalobiz_PYTHON = megalobiz.py + +megalobizdir = $(pkglibdir)/lyricsources/megalobiz + + +servicedir = $(datadir)/dbus-1/services +service_in_files = org.osdlyrics.LyricSourcePlugin.megalobiz.service.in +service_DATA = $(service_in_files:.service.in=.service) + +EXTRA_DIST = \ + $(service_in_files) \ + $(NULL) + +$(service_DATA): $(service_in_files) + @sed -e "s|\@pkglibdir\@|$(pkglibdir)|" -e "s|\@PYTHON\@|$(PYTHON)|" $< > $@ + +CLEANFILES = \ + org.osdlyrics.LyricSourcePlugin.megalobiz.service \ + $(NULL) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.5/lyricsources/megalobiz/megalobiz.py new/osdlyrics-0.5.7/lyricsources/megalobiz/megalobiz.py --- old/osdlyrics-0.5.5/lyricsources/megalobiz/megalobiz.py 1970-01-01 01:00:00.000000000 +0100 +++ new/osdlyrics-0.5.7/lyricsources/megalobiz/megalobiz.py 2021-05-24 23:50:17.000000000 +0200 @@ -0,0 +1,128 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2012 Tiger Soldier <[email protected]> +# +# This file is part of OSD Lyrics. +# +# OSD Lyrics is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# OSD Lyrics is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with OSD Lyrics. If not, see <https://www.gnu.org/licenses/>. +# + +from future import standard_library +standard_library.install_aliases() +from builtins import str, super +from urllib.parse import unquote + +import urllib.parse +import gettext +import html.parser +import html +import http.client +import re +import os + +from osdlyrics.lyricsource import BaseLyricSourcePlugin, SearchResult +from osdlyrics.utils import get_proxy_settings, http_download + +_ = gettext.gettext + +MEGALOBIZ_HOST = 'https://www.megalobiz.com' +MEGALOBIZ_SEARCH_PATH = '/search/all' +MEGALOBIZ_LYRIC_PATH = '/lrc/maker/' +MEGALOBIZ_DOWNLOAD_PATH = '/lrc/increment-downloads' +# Regexes to filter webpage content (search results page, and lyric page). +MEGALOBIZ_SEARCH_RESULT_PATTERN = re.compile(r'<a class=\"entity_name\".*?id=\"([0-9]+)\".*?name=\"(.*?)\".*?href=\"(.*?)\".+?</a>', re.DOTALL) +MEGALOBIZ_TITLE_ARTIST_SPLIT_PATTERN = re.compile(r'(.*?)(\sby\s|\s\-\s)(.*)', re.DOTALL) +MEGALOBIZ_LRC_PATTERN = re.compile(r'lyrics_details.*?<span.*?>(.*?)<\/span>', re.DOTALL) + +gettext.bindtextdomain('osdlyrics') +gettext.textdomain('osdlyrics') + + +class MegalobizSource(BaseLyricSourcePlugin): + """ Lyric source from https://www.megalobiz.com/ + """ + + def __init__(self): + super().__init__(id='megalobiz', name=_('megalobiz')) + + def do_search(self, metadata): + # Preparing keywords for search. + keys = [] + if metadata.artist: + keys.append('"' + metadata.artist + '"') + if metadata.title: + keys.append('"' + metadata.title + '"') + # Joining search terms. + urlkey = '+'.join(keys).replace(' ', '+') + # Building the URL. + url = MEGALOBIZ_HOST + MEGALOBIZ_SEARCH_PATH + # Request the HTTP page, storing its status and content. + status, content = http_download(url=url, + params={'qry': urlkey}, + proxy=get_proxy_settings(self.config_proxy)) + # Checking against HTTP response codes. + if status < 200 or status >= 400: + raise http.client.HTTPException(status, '') + # Filter all occurences of links belonging to search results. + matches = MEGALOBIZ_SEARCH_RESULT_PATTERN.findall(content.decode('utf8')) + # Populate osdlyrics' search results for the user to choose from. + result = [] + if matches: + for match in matches: + # The first three groups in a match are + # lyric_id, full_name (artist + song title) and lyric path. + # lyric_id = match[0] + full_name = match[1] + path = match[2] + # Decompose optimistically the full_name into artist and song title + name_parts = MEGALOBIZ_TITLE_ARTIST_SPLIT_PATTERN.findall(full_name) + if isinstance(name_parts, list) and len(name_parts) > 0: + name_parts = len(name_parts) > 0 and name_parts[0] or exit() + title = name_parts[1] == ' by ' and name_parts[0] or name_parts[2] + artist = name_parts[1] == ' by ' and name_parts[2] or name_parts[0] + # In case we can't split, use the full string as title. + else: + title = full_name + artist = '' + title = html.unescape(title) + artist = html.unescape(artist) + lyric_url = MEGALOBIZ_HOST + path + if path is not None: + result.append(SearchResult(title=title, + artist=artist, + sourceid=self.id, + downloadinfo=lyric_url)) + return result + + def do_download(self, downloadinfo): + ''' Download handler for this data source. + ''' + status, content = http_download(downloadinfo, + proxy=get_proxy_settings(self.config_proxy)) + # Checking against HTTP response codes. + if status < 200 or status >= 400: + raise http.client.HTTPException(status) + # Checking the presence of a HTTP payload. + if content: + content = MEGALOBIZ_LRC_PATTERN.search(content.decode('utf-8')).group(1) + # Replacing html breaks with new lines. + content = re.sub('<br>', "\n", content) + # Replace html entities present in the lyric content. + content = html.unescape(content) + return content.encode('utf-8') + + +if __name__ == '__main__': + mls = MegalobizSource() + mls._app.run() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.5/lyricsources/megalobiz/org.osdlyrics.LyricSourcePlugin.megalobiz.service.in new/osdlyrics-0.5.7/lyricsources/megalobiz/org.osdlyrics.LyricSourcePlugin.megalobiz.service.in --- old/osdlyrics-0.5.5/lyricsources/megalobiz/org.osdlyrics.LyricSourcePlugin.megalobiz.service.in 1970-01-01 01:00:00.000000000 +0100 +++ new/osdlyrics-0.5.7/lyricsources/megalobiz/org.osdlyrics.LyricSourcePlugin.megalobiz.service.in 2021-05-24 23:50:17.000000000 +0200 @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.osdlyrics.LyricSourcePlugin.megalobiz +Exec=@PYTHON@ @pkglibdir@/lyricsources/megalobiz/megalobiz.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.5/lyricsources/netease/netease.py new/osdlyrics-0.5.7/lyricsources/netease/netease.py --- old/osdlyrics-0.5.5/lyricsources/netease/netease.py 2021-05-19 14:09:33.000000000 +0200 +++ new/osdlyrics-0.5.7/lyricsources/netease/netease.py 2021-05-24 23:50:17.000000000 +0200 @@ -61,6 +61,18 @@ parsed = json.loads(content.decode('utf-8')) result = list(map(map_func, parsed['result']['songs'])) + # If there are more than 10 songs we do a second request. + song_count = parsed['result']['songCount'] + if song_count > 10: + params = params + '&offset=10' + status, content = http_download(url=url, + method='POST', + params=params.encode('utf-8'), + proxy=get_proxy_settings(self.config_proxy)) + if status < 200 or status >= 400: + raise http.client.HTTPException(status, '') + parsed = json.loads(content.decode('utf-8')) + result = result + list(map(map_func, parsed['result']['songs'])) return result def do_download(self, downloadinfo): @@ -71,12 +83,14 @@ raise http.client.HTTPException(status) parsed = json.loads(content.decode('utf-8')) - if 'nolyric' in parsed: + # Avoid processing results with no lyrics. + if 'nolyric' in parsed or 'uncollected' in parsed: raise ValueError('This item has no lyrics.') lyric = parsed['lrc']['lyric'] return lyric.encode('utf-8') + if __name__ == '__main__': netease = NeteaseSource() netease._app.run() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.5/lyricsources/subtitles4songs/Makefile.am new/osdlyrics-0.5.7/lyricsources/subtitles4songs/Makefile.am --- old/osdlyrics-0.5.5/lyricsources/subtitles4songs/Makefile.am 1970-01-01 01:00:00.000000000 +0100 +++ new/osdlyrics-0.5.7/lyricsources/subtitles4songs/Makefile.am 2021-05-24 23:50:17.000000000 +0200 @@ -0,0 +1,19 @@ +subtitles4songs_PYTHON = subtitles4songs.py + +subtitles4songsdir = $(pkglibdir)/lyricsources/subtitles4songs + + +servicedir = $(datadir)/dbus-1/services +service_in_files = org.osdlyrics.LyricSourcePlugin.subtitles4songs.service.in +service_DATA = $(service_in_files:.service.in=.service) + +EXTRA_DIST = \ + $(service_in_files) \ + $(NULL) + +$(service_DATA): $(service_in_files) + @sed -e "s|\@pkglibdir\@|$(pkglibdir)|" -e "s|\@PYTHON\@|$(PYTHON)|" $< > $@ + +CLEANFILES = \ + org.osdlyrics.LyricSourcePlugin.subtitles4songs.service \ + $(NULL) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.5/lyricsources/subtitles4songs/org.osdlyrics.LyricSourcePlugin.subtitles4songs.service.in new/osdlyrics-0.5.7/lyricsources/subtitles4songs/org.osdlyrics.LyricSourcePlugin.subtitles4songs.service.in --- old/osdlyrics-0.5.5/lyricsources/subtitles4songs/org.osdlyrics.LyricSourcePlugin.subtitles4songs.service.in 1970-01-01 01:00:00.000000000 +0100 +++ new/osdlyrics-0.5.7/lyricsources/subtitles4songs/org.osdlyrics.LyricSourcePlugin.subtitles4songs.service.in 2021-05-24 23:50:17.000000000 +0200 @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.osdlyrics.LyricSourcePlugin.subtitles4songs +Exec=@PYTHON@ @pkglibdir@/lyricsources/subtitles4songs/subtitles4songs.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.5/lyricsources/subtitles4songs/subtitles4songs.py new/osdlyrics-0.5.7/lyricsources/subtitles4songs/subtitles4songs.py --- old/osdlyrics-0.5.5/lyricsources/subtitles4songs/subtitles4songs.py 1970-01-01 01:00:00.000000000 +0100 +++ new/osdlyrics-0.5.7/lyricsources/subtitles4songs/subtitles4songs.py 2021-05-24 23:50:17.000000000 +0200 @@ -0,0 +1,113 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2012 Tiger Soldier <[email protected]> +# +# This file is part of OSD Lyrics. +# +# OSD Lyrics is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# OSD Lyrics is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with OSD Lyrics. If not, see <https://www.gnu.org/licenses/>. +# + +from future import standard_library +standard_library.install_aliases() +from builtins import str, super +from urllib.parse import unquote + +# import urlparse +import gettext +import html.parser +import http.client +import re + +from osdlyrics.lyricsource import BaseLyricSourcePlugin, SearchResult +from osdlyrics.utils import get_proxy_settings, http_download + +_ = gettext.gettext + +S4S_HOST = 'https://www.rentanadviser.com' +S4S_SEARCH_PATH = '/en/subtitles/subtitles4songs.aspx' +S4S_SUBTITLE_PATH = '/en/subtitles/getsubtitle.aspx' +# Regexes to filter webpage content (search results page, and lyric page). +S4S_SEARCH_RESULT_PATTERN = re.compile(r'<a [^<]*?href="getsubtitle\.aspx(\?artist=.*?song=.*?)">', re.DOTALL) +S4S_LRC_PATTERN = re.compile(r'<span id="ctl00_ContentPlaceHolder1_lbllyrics"><h3>(.*?)<\/h3>(.*?)<\/span>', re.DOTALL) +TITLE_PATTERN = re.compile(r'&song=(.*$)') +ARTIST_PATTERN = re.compile(r'artist=(.*?)&') +BRAND_PATTERN = r"^.*RentAnAdviser\.com.*$" + +gettext.bindtextdomain('osdlyrics') +gettext.textdomain('osdlyrics') + + +class Subtitles4songsSource(BaseLyricSourcePlugin): + """ Lyric source from https://www.rentanadviser.com/en/subtitles/subtitles4songs.aspx + """ + + def __init__(self): + super().__init__(id='subtitles4songs', name=_('subtitles4songs')) + + def do_search(self, metadata): + # Preparing keywords for search. + keys = [] + if metadata.artist: + keys.append(metadata.artist) + if metadata.title: + keys.append(metadata.title) + # Joining search terms. + urlkey = '+'.join(keys).replace(' ', '+') + # Building the URL. + url = S4S_HOST + S4S_SEARCH_PATH + # Request the HTTP page, storing its status and content. + status, content = http_download(url=url, + params={'q': urlkey}, + proxy=get_proxy_settings(self.config_proxy)) + # Checking against HTTP response codes. + if status < 200 or status >= 400: + raise http.client.HTTPException(status, '') + # Filter all occurences of links belonging to search results. + matches = S4S_SEARCH_RESULT_PATTERN.findall(content.decode('utf8')) + # Populate osdlyrics' search results for the user to choose from. + result = [] + if matches: + for match in matches: + # Decompose the HTML matches into title, artist and url. + title = unquote(TITLE_PATTERN.search(match).group(1)) + artist = unquote(ARTIST_PATTERN.search(match).group(1)) + # Build a download URL for this match. + url = S4S_HOST + S4S_SUBTITLE_PATH + match + "&type=lrc" + # Add the match metadata for the window with search results. + if url is not None: + result.append(SearchResult(title=title, + artist=artist, + sourceid=self.id, + downloadinfo=url)) + return result + + def do_download(self, downloadinfo): + status, content = http_download(downloadinfo, + proxy=get_proxy_settings(self.config_proxy)) + # Checking against HTTP response codes. + if status < 200 or status >= 400: + raise http.client.HTTPException(status) + # Checking the presence of a HTTP payload. + if content: + content = S4S_LRC_PATTERN.search(content.decode('utf8')).group(2) + # Replacing html breaks with new lines. + content = re.sub('<br />', "\n", content) + # Debrand the lyrics. + content = re.sub(BRAND_PATTERN, " ", content, 0, re.MULTILINE) + return content.encode('utf-8') + + +if __name__ == '__main__': + s4s = Subtitles4songsSource() + s4s._app.run() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.5/lyricsources/viewlyrics/Makefile.am new/osdlyrics-0.5.7/lyricsources/viewlyrics/Makefile.am --- old/osdlyrics-0.5.5/lyricsources/viewlyrics/Makefile.am 2021-05-19 14:09:33.000000000 +0200 +++ new/osdlyrics-0.5.7/lyricsources/viewlyrics/Makefile.am 1970-01-01 01:00:00.000000000 +0100 @@ -1,19 +0,0 @@ -viewlyrics_PYTHON = viewlyrics.py - -viewlyricsdir = $(pkglibdir)/lyricsources/viewlyrics - - -servicedir = $(datadir)/dbus-1/services -service_in_files = org.osdlyrics.LyricSourcePlugin.viewlyrics.service.in -service_DATA = $(service_in_files:.service.in=.service) - -EXTRA_DIST = \ - $(service_in_files) \ - $(NULL) - -$(service_DATA): $(service_in_files) - @sed -e "s|\@pkglibdir\@|$(pkglibdir)|" -e "s|\@PYTHON\@|$(PYTHON)|" $< > $@ - -CLEANFILES = \ - org.osdlyrics.LyricSourcePlugin.viewlyrics.service \ - $(NULL) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.5/lyricsources/viewlyrics/org.osdlyrics.LyricSourcePlugin.viewlyrics.service.in new/osdlyrics-0.5.7/lyricsources/viewlyrics/org.osdlyrics.LyricSourcePlugin.viewlyrics.service.in --- old/osdlyrics-0.5.5/lyricsources/viewlyrics/org.osdlyrics.LyricSourcePlugin.viewlyrics.service.in 2021-05-19 14:09:33.000000000 +0200 +++ new/osdlyrics-0.5.7/lyricsources/viewlyrics/org.osdlyrics.LyricSourcePlugin.viewlyrics.service.in 1970-01-01 01:00:00.000000000 +0100 @@ -1,3 +0,0 @@ -[D-BUS Service] -Name=org.osdlyrics.LyricSourcePlugin.viewlyrics -Exec=@PYTHON@ @pkglibdir@/lyricsources/viewlyrics/viewlyrics.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.5/lyricsources/viewlyrics/viewlyrics.py new/osdlyrics-0.5.7/lyricsources/viewlyrics/viewlyrics.py --- old/osdlyrics-0.5.5/lyricsources/viewlyrics/viewlyrics.py 2021-05-19 14:09:33.000000000 +0200 +++ new/osdlyrics-0.5.7/lyricsources/viewlyrics/viewlyrics.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,134 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2012 PedroHLC <[email protected]> -# -# This file is part of OSD Lyrics. -# -# OSD Lyrics is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OSD Lyrics is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with OSD Lyrics. If not, see <https://www.gnu.org/licenses/>. -# -from __future__ import unicode_literals -from future import standard_library -standard_library.install_aliases() -from builtins import bytes, super - -import hashlib -import http.client -import string -import unicodedata -import xml.etree.ElementTree as xet - -from osdlyrics.lyricsource import BaseLyricSourcePlugin, SearchResult -from osdlyrics.utils import get_proxy_settings, http_download - -VIEWLYRICS_HOST = 'search.crintsoft.com' -VIEWLYRICS_SEARCH_URL = '/searchlyrics.htm' -VIEWLYRICS_BASE_LRC_URL = 'http://viewlyrics.com/' - -VIEWLYRICS_QUERY_FORM = '<?xml version=\'1.0\' encoding=\'utf-8\' ?><searchV1 artist="%artist" title="%title"%etc />' -VIEWLYRICS_AGENT = 'MiniLyrics' -VIEWLYRICS_KEY = b'Mlv1clt4.0' - - -def normalize_str(s): - """ If s is a unicode string, only keep alphanumeric characters and remove - diacritics - """ - return ''.join(x for x in unicodedata.normalize('NFKD', s) - if x in string.ascii_letters + string.digits).lower() - - -class ViewlyricsSource(BaseLyricSourcePlugin): - def __init__(self): - super().__init__(id='viewlyrics', name='ViewLyrics') - - def do_search(self, metadata): - # type: (osdlyrics.metadata.Metadata) -> List[SearchResult] - title = metadata.title or '' - artist = metadata.artist or '' - - result = [] - page = 0 - pagesleft = 1 - while pagesleft > 0: - pageresult, pagesleft = self.real_search(title, artist, page) - result += pageresult - page += 1 - - # Remove non-lrc (plain text) results, they cannot be displayed by - # OSDLyrics for now - result = [r for r in result if r._downloadinfo.endswith('.lrc')] - - # Prioritize results whose artist matches - if metadata.artist and metadata.title: - n_artist = normalize_str(artist) - - def res_has_same_artist(result): - return normalize_str(result._artist) == n_artist - result.sort(key=res_has_same_artist, reverse=True) - - return result - - def real_search(self, title='', artist='', page=0): - query = VIEWLYRICS_QUERY_FORM - query = query.replace('%title', title) - query = query.replace('%artist', artist) - query = query.replace('%etc', ' client="MiniLyrics" RequestPage=\'%d\'' % page) # Needs real RequestPage - query = query.encode('utf-8') - - queryhash = hashlib.md5() - queryhash.update(query) - queryhash.update(VIEWLYRICS_KEY) - - masterquery = b'\2\0\4\0\0\0' + queryhash.digest() + query - - url = VIEWLYRICS_HOST + VIEWLYRICS_SEARCH_URL - status, content = http_download(url=url, - method='POST', - params=masterquery, - proxy=get_proxy_settings(self.config_proxy)) - - if status < 200 or status >= 400: - raise http.client.HTTPException(status, '') - - contentbytes = bytearray(content) - codekey = contentbytes[1] - deccontent = bytes(map(codekey.__xor__, contentbytes[22:])) - - root = xet.fromstring(deccontent) # tagName == 'return' - pagesleft = int(next((v for k, v in root.items() if k.lower() == 'PageCount'.lower()), 0)) - result = [ - SearchResult( - title=entry.get('title', ''), - artist=entry.get('artist', ''), - album=entry.get('album', ''), - sourceid=self.id, - downloadinfo=VIEWLYRICS_BASE_LRC_URL + entry.get('link'), - ) - for entry in root.findall('fileinfo[@link]') - ] - return result, (pagesleft - page) - - def do_download(self, downloadinfo): - # type: (Any) -> bytes - # `downloadinfo` is what you set in SearchResult - status, content = http_download(url=downloadinfo, - proxy=get_proxy_settings(self.config_proxy)) - if status < 200 or status >= 400: - raise http.client.HTTPException(status, '') - return content - - -if __name__ == '__main__': - viewlyrics = ViewlyricsSource() - viewlyrics._app.run() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.5/po/POTFILES.in new/osdlyrics-0.5.7/po/POTFILES.in --- old/osdlyrics-0.5.5/po/POTFILES.in 2021-05-19 14:09:33.000000000 +0200 +++ new/osdlyrics-0.5.7/po/POTFILES.in 2021-05-24 23:50:17.000000000 +0200 @@ -11,5 +11,7 @@ src/ol_scroll_window.c data/dialogs.glade data/osdlyrics.desktop.in +lyricsources/megalobiz/megalobiz.py lyricsources/netease/netease.py lyricsources/xiami/xiami.py +lyricsources/subtitles4songs/subtitles4songs.py ++++++ osdlyrics.appdata.xml ++++++ --- /var/tmp/diff_new_pack.pWCBTV/_old 2021-11-22 23:05:29.369669206 +0100 +++ /var/tmp/diff_new_pack.pWCBTV/_new 2021-11-22 23:05:29.369669206 +0100 @@ -35,17 +35,11 @@ <url type="homepage">https://github.com/osdlyrics/osdlyrics</url> <url type="bugtracker">https://github.com/osdlyrics/osdlyrics/issues</url> <releases> - <release version="0.5.5-RC2" date="2020-04-20"> + <release version="0.5.7" date="2021-05-25"> <description> <p> - Fix python logging - </p> - </description> - </release> - <release version="0.5.5-RC1" date="2019-03-30"> - <description> - <p> - Fixes autoreconf with "foreign" flag + Netease: Show more results + Add Megalobiz </p> </description> </release>
