brenns10 / tswift

MetroLyrics API for Python
BSD 3-Clause "New" or "Revised" License
52 stars 15 forks source link

Error while retrieving lyrics - ValueError: Input object is not an XML element: HtmlComment #6

Closed nizzit closed 7 years ago

nizzit commented 7 years ago
Traceback (most recent call last):
  File "./tswift.py", line 202, in <module>
    main()
  File "./tswift.py", line 198, in main
    print(song.format())
  File "./tswift.py", line 84, in format
    self.lyrics,
  File "./tswift.py", line 76, in lyrics
    self.load()
  File "./tswift.py", line 69, in load
    verses = [c.text_content() for c in lyric_div]
  File "./tswift.py", line 69, in <listcomp>
    verses = [c.text_content() for c in lyric_div]
  File "/usr/local/lib/python3.5/dist-packages/lxml/html/__init__.py", line 420, in text_content
    return _collect_string_content(self)
  File "src/lxml/xpath.pxi", line 433, in lxml.etree.XPath.__call__ (src/lxml/lxml.etree.c:174192)
  File "src/lxml/apihelpers.pxi", line 67, in lxml.etree._rootNodeOrRaise (src/lxml/lxml.etree.c:17443)
ValueError: Input object is not an XML element: HtmlComment

I think this is because in lyric_di contains not only objects like HtmlComment. It is expected that all elements of lyric_div contain the method text_content, but HtmlComment does not have this method.