Giter VIP home page Giter VIP logo

songtext's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

songtext's Issues

Remove abstract base classes

APIs have different designs, so it's silly to force the use of abstract base classes when developing new modules.

Trying to return lyrics for a song with full lyrics unavailable raises unhandled IndexError (LYRICSnMUSIC api)

$ 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

Choose an API

  • MetroLyrics
  • LyricFind / The Echo Nest
  • Musixmatch
  • LYRICSnMUSIC (api)
  • ChartLyrics
  • LyricWiki

Upgrade Python

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.

api-specific help text

Modify help text such that the help text outputs the options available for the specified API.

Tests for the lyricsnmusic api are failing

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

Fix unicode issues

$ 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

Consider switching from lxml's clean_html for enhanced security (and possibly performance)

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:

  • Bleach is a widely adopted Python library specifically designed for sanitizing and cleaning HTML input.
  • It has a strong track record in terms of security – it's allowed-list-based.
  • It was deprecated in January but it will still receive security updates, support for new Pythons and bugfixes, see upstream issue.

nh3:

  • nh3 is Python binding for the ammonia library. Ammonia is written in Rust and it's also allowed-list-based.
  • Thanks to the Rust backend, nh3 is also significantly faster than bleach.
  • Rust backend is nothing to be afraid of. nh3 uses the latest PyO3 compatible with Python 3.12 and provides wheels built on top of compatible ABI for different architectures and platforms.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.