ysim / songtext Goto Github PK
View Code? Open in Web Editor NEWcommand-line song lyric fetcher
Home Page: https://pypi.python.org/pypi/songtext/
License: BSD 2-Clause "Simplified" License
command-line song lyric fetcher
Home Page: https://pypi.python.org/pypi/songtext/
License: BSD 2-Clause "Simplified" License
Otherwise build will keep failing, because an api key is needed for the lyricsnmusic unit tests.
Refer to:
argparse is in the stdlib
APIs have different designs, so it's silly to force the use of abstract base classes when developing new modules.
Two things:
There is no exception handling for the fact that -w
must be used in conjunction with -l
or with -i N
Raise NotImplementedError for mandatory methods
$ songtext --api lyricsnmusic -t 'the point of no return' -l
40 track(s) matched your search query.
Displaying the top 10 matches:
0. : The Point of No Return
("Passarino - go away!"...)
1. Geto Boys: Point of No Return
("Intro:"...)
2. Electric Light Orchestra: Point of No Return [#] (full lyrics unavailable)
3. Duran Duran: Point of No Return
("The random aspects of our lives"...)
4. Andrew Lloyd Webber: Point of No Return
("You have come here"...)
5. Buzzcocks: Point of No Return
("If I could discover"...)
6. Andrew Lloyd Webber and London Symphony Orchestra: The point of no return
("You have come here"...)
7. Status Quo: Point of No Return (full lyrics unavailable)
8. Paul Weller: Whole Point of No Return
("The Lords and Ladies pass a ruling."...)
9. Napalm Death: Point of No Return
("Systematic rape of nature"...)
ysim:~$ songtext --api lyricsnmusic -t 'the point of no return' -i 2
40 track(s) matched your search query.
Traceback (most recent call last):
File "/usr/local/bin/songtext", line 9, in <module>
load_entry_point('songtext==0.1.5', 'console_scripts', 'songtext')()
File "/usr/local/lib/python2.7/site-packages/libsongtext/songtext.py", line 48, in main
cli()
File "/usr/local/lib/python2.7/site-packages/click/core.py", line 716, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/site-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/libsongtext/songtext.py", line 43, in cli
return getattr(api_module, 'get_result')(params)
File "/usr/local/lib/python2.7/site-packages/libsongtext/lyricsnmusic.py", line 107, in get_result
output_song(tracklist.get_lyrics(), args['no_pager'])
File "/usr/local/lib/python2.7/site-packages/libsongtext/lyricsnmusic.py", line 89, in get_lyrics
element = page_html.cssselect(self.CSS_SELECTOR)[0]
IndexError: list index out of range
To reduce quickstart barrier (LYRICSnMUSIC requires an API key to perform queries).
Stupid connection errors
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Traceback:
requests.exceptions.ConnectionError: HTTPConnectionPool(host='api.chartlyrics.com', port=80): Max retries exceeded with url: /apiv1.asmx/SearchLyric?artist=led+zeppelin&song=stairway+to+heaven (Caused by <class 'socket.error'>: [Errno 54] Connection reset by peer)
This might help: http://stackoverflow.com/questions/20608443/python-requests-multithreading-max-retries-exceeded-with-url-caused-by-class
Modify help text such that the help text outputs the options available for the specified API.
-_-
They're currently not rendering as links after converting it from README.md
.
PyPI doesn't allow you to replace a package, so just create a new release (v0.1.7
).
See stacktrace:
$ make test
pytest tests/
============================ test session starts ============================
platform darwin -- Python 2.7.13, pytest-3.0.1, py-1.4.31, pluggy-0.3.1
rootdir: /Users/yiqing/Repos/songtext, inifile:
collected 16 items
tests/test_api_integrations.py .....FFFFFFFFF
tests/test_local_options.py ..
================================= FAILURES ==================================
____ TestLyricsNMusic.test_get_single_result_with_artist_and_song_title _____
self = <tests.test_api_integrations.TestLyricsNMusic instance at 0x1060cf5f0>
def test_get_single_result_with_artist_and_song_title(self):
result = runner.invoke(songtext.cli, [
'--api', 'lyricsnmusic',
'-a', 'Tove Lo',
'-t', 'Talking Body'
])
> assert result.exit_code == 0
E assert -1 == 0
E + where -1 = <Result ValueError('No JSON object could be decoded',)>.exit_code
tests/test_api_integrations.py:46: AssertionError
____________ TestLyricsNMusic.test_get_single_result_with_words _____________
self = <tests.test_api_integrations.TestLyricsNMusic instance at 0x1060a8950>
def test_get_single_result_with_words(self):
result = runner.invoke(songtext.cli, [
'--api', 'lyricsnmusic',
'-w', 'two hearts fading',
'--no-pager'
])
> assert result.exit_code == 0
E assert -1 == 0
E + where -1 = <Result ValueError('No JSON object could be decoded',)>.exit_code
tests/test_api_integrations.py:55: AssertionError
_________ TestLyricsNMusic.test_get_list_with_artist_and_song_title _________
self = <tests.test_api_integrations.TestLyricsNMusic instance at 0x10576add0>
def test_get_list_with_artist_and_song_title(self):
result = runner.invoke(songtext.cli, [
'--api', 'lyricsnmusic',
'-a', 'David Bowie',
'-t', 'Heroes'
])
> assert result.exit_code == 0
E assert -1 == 0
E + where -1 = <Result ValueError('No JSON object could be decoded',)>.exit_code
tests/test_api_integrations.py:64: AssertionError
______________ TestLyricsNMusic.test_get_list_with_limit_of_20 ______________
self = <tests.test_api_integrations.TestLyricsNMusic instance at 0x106122fc8>
def test_get_list_with_limit_of_20(self):
result = runner.invoke(songtext.cli, [
'--api', 'lyricsnmusic',
'love', '-l', '--limit', '20'
])
> assert result.exit_code == 0
E assert -1 == 0
E + where -1 = <Result ValueError('No JSON object could be decoded',)>.exit_code
tests/test_api_integrations.py:72: AssertionError
______ TestLyricsNMusic.test_get_list_with_only_limit_option_specified ______
self = <tests.test_api_integrations.TestLyricsNMusic instance at 0x1061205f0>
def test_get_list_with_only_limit_option_specified(self):
"""
You should still get a list back even if you only specify --limit
and not -l/--show-list
"""
result = runner.invoke(songtext.cli, [
'--api', 'lyricsnmusic',
'-a', 'Rob Thomas',
'-t' 'This is How a Heart Breaks',
'--limit', '5'
])
> assert result.exit_code == 0
E assert -1 == 0
E + where -1 = <Result ValueError('No JSON object could be decoded',)>.exit_code
tests/test_api_integrations.py:87: AssertionError
_________________ TestLyricsNMusic.test_get_song_with_index _________________
self = <tests.test_api_integrations.TestLyricsNMusic instance at 0x1061180e0>
def test_get_song_with_index(self):
result = runner.invoke(songtext.cli, [
'--api', 'lyricsnmusic',
'-a', 'Kiesza',
'-t', 'Hideaway',
'-i', '1',
'--no-pager'
])
> assert result.exit_code == 0
E assert -1 == 0
E + where -1 = <Result ValueError('No JSON object could be decoded',)>.exit_code
tests/test_api_integrations.py:99: AssertionError
_____________ TestLyricsNMusic.test_error_on_out_of_range_index _____________
sel = <tests.test_api_integrations.TestLyricsNMusic instance at 0x1060e44d0>
def test_error_on_out_of_range_index(sel):
result = runner.invoke(songtext.cli, [
'--api', 'lyricsnmusic',
'-a', 'Eminem',
'-t', 'Lose Yourself',
'-i', '30'
])
> assert 'out of range' in result.output
E assert 'out of range' in ''
E + where '' = <Result ValueError('No JSON object could be decoded',)>.output
tests/test_api_integrations.py:109: AssertionError
______________ TestLyricsNMusic.test_get_list_with_artist_only ______________
self = <tests.test_api_integrations.TestLyricsNMusic instance at 0x1060d0d88>
def test_get_list_with_artist_only(self):
result = runner.invoke(songtext.cli, [
'--api', 'lyricsnmusic',
'-a', 'Zara Larsson',
'-l'
])
> assert result.exit_code == 0
E assert -1 == 0
E + where -1 = <Result ValueError('No JSON object could be decoded',)>.exit_code
tests/test_api_integrations.py:118: AssertionError
____________ TestLyricsNMusic.test_get_list_with_song_title_only ____________
self = <tests.test_api_integrations.TestLyricsNMusic instance at 0x1055fad88>
def test_get_list_with_song_title_only(self):
result = runner.invoke(songtext.cli, [
'--api', 'lyricsnmusic',
'-t', 'Defying Gravity',
'-l'
])
> assert result.exit_code == 0
E assert -1 == 0
E + where -1 = <Result ValueError('No JSON object could be decoded',)>.exit_code
tests/test_api_integrations.py:127: AssertionError
=================== 9 failed, 7 passed in 400.26 seconds ====================
make: *** [test] Error 1
$ songtext -a 'cœur de pirate' -t 'comme des enfants' --no-pager
C�ur De Pirate: Comme Des Enfants
----------------------------------
Alors tu vois comme tout se mêle
Et du cœur à tes lèvres je deviens un casse-tête
Ton rire me crie de te lâcher
Avant de perdre prise et d'abandonner
I'd like to bring to your attention that we are discussing the possibility of removing lxml's clean_html functionality from lxml library. Over the past years, there have been several concerning security vulnerabilities discovered within the lxml library's clean_html functionality – CVE-2021-43818, CVE-2021-28957, CVE-2020-27783, CVE-2018-19787 and CVE-2014-3146.
The main problem is in the design. Because the lxml's clean_html functionality is based on a blocklist, it's hard to keep it up to date with all new possibilities in HTML and JS.
Two viable alternatives worth considering are bleach
and nh3
. Here's why:
bleach:
nh3:
We'll probably move the cleaning part of the lxml to a distinct project first so it will still be possible to use it but better is to find a suitable alternative sooner rather than later.
Let me know if we can help you with this transition anyhow and have a nice day.
Because that's what they are (API tests!)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.