JimmXinu / FanFicFare

FanFicFare is a tool for making eBooks from stories on fanfiction and other web sites.
Other
739 stars 157 forks source link

Malformed class selector processing story with footnote on ao3 #966

Closed HowardJeng closed 1 year ago

HowardJeng commented 1 year ago

FanFicFare Calibre plugin version 4.24.0 when overwriting https://archiveofourown.org/works/42046374 there's a Malformed class selector exception. This seems to be related to a footnote in chapter 4. However, this same story downloaded fine on May 28, which also included chapter 4. Updating, not overwriting did work.

FFF: INFO: 2023-06-17 13:24:19,175: calibre_plugins.fanficfare_plugin.jobs(434): Exception: {'title': 'Three Jedi, Two Clones, and One Force Anomaly', 'author_sort': ['soft_but_gremlin'], 'author': ['soft_but_gremlin'], 'comments': '<div class="userstuff">\n              <p>Being a new parent is difficult. Being a new parent to de-aged soldiers with knowledge of the future, a general mistrust of everyone, and a habit of keeping secrets, all in the middle of a tense situation between historic enemies...well, that is slightly more difficult.</p><p>(Sequel to <i>Free Jedi to Good Home</i>)</p>\n            </div>', 'good': False, 'status': 'Error', 'showerror': True, 'calibre_id': 3105, 'begin': None, 'end': None, 'comment': 'Malformed class selector at position 6\n  line 1:\n#note4.1\n      ^', 'url': 'https://archiveofourown.org/works/42046374', 'site': 'archiveofourown.org', 'series': 'One Hundred Hours To Rearrange The Stars [2]', 'added': False, 'pubdate': datetime.datetime(2022, 9, 30, 0, 0, tzinfo=SafeLocalTimeZone()), 'publisher': 'archiveofourown.org', 'uniqueurl': 'https://archiveofourown.org/works/42046374[None-None]', 'listorder': 21, 'collision': 'Overwrite if Newer', 'is_adult': False, 'username': 'NoneGiven', 'password': '', 'icon': 'dialog_error.png', 'all_metadata': {'category': 'Star Wars - All Media Types, Star Wars Legends: Jango Fett Open Seasons (Comics), Star Wars Prequel Trilogy, Star Wars: The Clone Wars (2008) - All Media Types', 'genre': 'Age Regression/De-Aging, Alternate Universe - Time Travel, Battle of Galidraan Happened Differently (Star Wars), Gen, Jedi Lineages (Star Wars), Mandalorian Adoption (Star Wars), Planet Telos IV | Telos (Star Wars)', 'characters': 'Ahsoka Tano, Anakin Skywalker, Andra (Star Wars), CC-2224 | Cody, CT-7567 | Rex, Denetrus (Star Wars), Dooku | Darth Tyranus, Jango Fett, Kit Fisto, Myles the Mandalorian (Star Wars), Obi-Wan Kenobi, Qui-Gon Jinn, Savage Opress, Xanatos (Star Wars)', 'ships': 'Dooku & Obi-Wan Kenobi, Dooku & Qui-Gon Jinn, Jango Fett & CT-7567 | Rex, Kit Fisto & Obi-Wan Kenobi, Obi-Wan Kenobi & Anakin Skywalker & Ahsoka Tano, Obi-Wan Kenobi & Myles the Mandalorian, Qui-Gon Jinn & Obi-Wan Kenobi, Qui-Gon Jinn & Xanatos', 'warnings': 'No Archive Warnings Apply', 'extratags': 'FanFiction', 'author': 'soft_but_gremlin', 'authorId': 'soft_but_gremlin', 'authorUrl': 'https://archiveofourown.org/users/soft_but_gremlin/pseuds/soft_but_gremlin', 'lastupdate': 'Last Update Year/Month: 2023/06, Last Update: 2023/06/11', 'series': 'One Hundred Hours To Rearrange The Stars [2]', 'seriesUrl': 'https://archiveofourown.org/series/2946915', 'language': 'English', 'status': 'In-Progress', 'datePublished': '2022-09-30', 'dateUpdated': '2023-06-11', 'dateCreated': '2023-06-17 13:19:33', 'rating': 'Teen And Up Audiences', 'numChapters': '18', 'numWords': '92,747', 'words_added': '', 'site': 'archiveofourown.org', 'publisher': 'archiveofourown.org', 'storyId': '42046374', 'title': 'Three Jedi, Two Clones, and One Force Anomaly', 'titleHTML': "<a class='titlelink' href='https://archiveofourown.org/works/42046374'>Three Jedi, Two Clones, and One Force Anomaly</a>", 'storyUrl': 'https://archiveofourown.org/works/42046374', 'sectionUrl': 'https://archiveofourown.org/works/42046374', 'description': '<div class="userstuff">\n              <p>Being a new parent is difficult. Being a new parent to de-aged soldiers with knowledge of the future, a general mistrust of everyone, and a habit of keeping secrets, all in the middle of a tense situation between historic enemies...well, that is slightly more difficult.</p><p>(Sequel to <i>Free Jedi to Good Home</i>)</p>\n            </div>', 'formatname': '', 'formatext': '', 'siteabbrev': 'ao3', 'version': 'FanFicFare v4.24.0', 'authorHTML': "<a class='authorlink' href='https://archiveofourown.org/users/soft_but_gremlin/pseuds/soft_but_gremlin'>soft_but_gremlin</a>", 'seriesHTML': "<a class='serieslink' href='https://archiveofourown.org/series/2946915'>One Hundred Hours To Rearrange The Stars [2]</a>", 'langcode': 'en', 'output_css': '', 'cover_image': '', 'fandoms': 'Star Wars - All Media Types, Star Wars Legends: Jango Fett Open Seasons (Comics), Star Wars Prequel Trilogy, Star Wars: The Clone Wars (2008) - All Media Types', 'freeformtags': 'Age Regression/De-Aging, Alternate Universe - Time Travel, Battle of Galidraan Happened Differently (Star Wars), Jedi Lineages (Star Wars), Mandalorian Adoption (Star Wars), Planet Telos IV | Telos (Star Wars)', 'freefromtags': 'Age Regression/De-Aging, Alternate Universe - Time Travel, Battle of Galidraan Happened Differently (Star Wars), Jedi Lineages (Star Wars), Mandalorian Adoption (Star Wars), Planet Telos IV | Telos (Star Wars)', 'ao3categories': 'Gen', 'comments': '1,875', 'chapterslashtotal': '18/?', 'chapterstotal': '?', 'kudos': '3,367', 'hits': '74,828', 'bookmarks': '630', 'collections': '', 'byline': 'soft_but_gremlin', 'bookmarked': '', 'bookmarktags': '', 'bookmarksummary': '', 'bookmarkprivate': '', 'bookmarkrec': '', 'restricted': '', 'series00': 'One Hundred Hours To Rearrange The Stars [2]', 'series01': '', 'series02': '', 'series03': '', 'series00Url': 'https://archiveofourown.org/series/2946915', 'series01Url': '', 'series02Url': '', 'series03Url': '', 'series00HTML': "<a class='series00link' href='https://archiveofourown.org/series/2946915'>One Hundred Hours To Rearrange The Stars [2]</a>", 'series01HTML': '', 'series02HTML': '', 'series03HTML': ''}, 'tags': ['CT-7567 | Rex', 'Obi-Wan Kenobi & Anakin Skywalker & Ahsoka Tano', 'Alternate Universe - Time Travel', 'Dooku | Darth Tyranus', 'Star Wars Prequel Trilogy', 'Star Wars - All Media Types', 'Myles the Mandalorian (Star Wars)', 'Jango Fett', 'Star Wars: The Clone Wars (2008) - All Media Types', 'Dooku & Obi-Wan Kenobi', 'Gen', 'Star Wars Legends: Jango Fett Open Seasons (Comics)', 'Andra (Star Wars)', 'Qui-Gon Jinn & Xanatos', 'Kit Fisto & Obi-Wan Kenobi', 'In-Progress', 'Mandalorian Adoption (Star Wars)', 'Ahsoka Tano', 'Age Regression/De-Aging', 'Xanatos (Star Wars)', 'Obi-Wan Kenobi & Myles the Mandalorian', 'CC-2224 | Cody', 'Kit Fisto', 'Denetrus (Star Wars)', 'Anakin Skywalker', 'Qui-Gon Jinn', 'Battle of Galidraan Happened Differently (Star Wars)', 'FanFiction', 'Obi-Wan Kenobi', 'Qui-Gon Jinn & Obi-Wan Kenobi', 'Jedi Lineages (Star Wars)', 'Dooku & Qui-Gon Jinn', 'Jango Fett & CT-7567 | Rex', 'Planet Telos IV | Telos (Star Wars)', 'Savage Opress'], 'updatedate': datetime.datetime(2023, 6, 11, 0, 0, tzinfo=SafeLocalTimeZone()), 'timestamp': datetime.datetime(2023, 6, 17, 13, 24, 8, 843391, tzinfo=SafeLocalTimeZone()), 'fileupdated': datetime.datetime(2023, 5, 28, 12, 57, 49), 'epub_for_update': 'C:\\Users\\hjeng\\AppData\\Local\\Temp\\calibre_4wwkqfo0\\fanficfare_m14j5q62\\old-3105-d_sfre79.epub', 'calibre_columns': {}, 'outfile': 'C:\\Users\\hjeng\\AppData\\Local\\Temp\\calibre_4wwkqfo0\\fanficfare_m14j5q62\\Three Jedi_ Two Clones_ and One Force Anomaly-soft_but_gremlin-wwd34m_a.epub'}:Malformed class selector at position 6
  line 1:
#note4.1
      ^
Traceback (most recent call last):
  File "calibre_plugins.fanficfare_plugin.jobs", line 303, in do_download_for_worker
  File "C:\Users\hjeng\AppData\Roaming\calibre\plugins\FanFicFare.zip\fanficfare\writers\base_writer.py", line 204, in writeStory
  File "C:\Users\hjeng\AppData\Roaming\calibre\plugins\FanFicFare.zip\fanficfare\adapters\base_adapter.py", line 250, in getStory
  File "C:\Users\hjeng\AppData\Roaming\calibre\plugins\FanFicFare.zip\fanficfare\adapters\adapter_archiveofourownorg.py", line 575, in getChapterTextNum
  File "C:\Users\hjeng\AppData\Roaming\calibre\plugins\FanFicFare.zip\fanficfare\adapters\base_adapter.py", line 623, in utf8FromSoup
  File "C:\Users\hjeng\AppData\Roaming\calibre\plugins\FanFicFare.zip\fanficfare\adapters\base_adapter.py", line 696, in _do_utf8FromSoup
  File "bs4\element.py", line 1914, in select_one
  File "bs4\element.py", line 1949, in select
  File "soupsieve\__init__.py", line 144, in select
  File "soupsieve\__init__.py", line 67, in compile
  File "soupsieve\css_parser.py", line 222, in _cached_css_compile
  File "soupsieve\css_parser.py", line 1159, in process_selectors
  File "soupsieve\css_parser.py", line 985, in parse_selectors
  File "soupsieve\css_parser.py", line 1152, in selector_iter
soupsieve.util.SelectorSyntaxError: Malformed class selector at position 6
  line 1:
#note4.1
      ^
JimmXinu commented 1 year ago

That code was added for #952 to better support internal page links. I rashly assumed that I could use the anchor as an id selector unchanged. This story/author uses id attributes that contain ., with the error you see.

Test versions are up and they work for me. Let me know if you run into any more cases.