JimmXinu / FanFicFare

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

[bug]: Fiction.live images are not showing #922

Closed Jemeni11 closed 1 year ago

Jemeni11 commented 1 year ago

I have no idea how this happened but now when I download stories from fiction.live, except for the cover image, none of the images in the story show up. I just get a broken image icon as a placeholder. I opened the epub and weirdly enough, the images are there.

However, in the chapter's xhtml file, the image tag looks like this:

<p>
  <img longdesc="failedtoload" src="failedtoload"/>
</p>

Fanficfare CLI v4.20.2

My Personal.ini: https://github.com/Jemeni11/hosting-pics/blob/main/personal.ini The URL of the story: https://fiction.live/stories/Star-Wars-Clone-Wars/NHyoqL7owi26gdMpx/home The story epub: https://github.com/Jemeni11/hosting-pics/blob/main/Star%20Wars_%20Clone%20Wars%20(Ch%201-10)-flive_NHyoqL7owi26gdMpx.epub

JimmXinu commented 1 year ago

@HazelSh, do you have any time to look at this?

I found myself a bit baffled by adapter_fictionlive.py. For example, why doesn't the story above (I ran it with -e 10 to limit to first 10 chapters) not have a file0001.xhtml in the epub?

HazelSh commented 1 year ago

I'll give it a brief look. I absolutely am available to answer design/concept questions about adapter_fictionlive.py. I'm not sure why that story is missing that file (and starts at ch2 in my e-reader); it may be an accurate representation of something funny going on with that story on the site. I'll look into that as well.

Able to reproduce the issue locally, got broken-image placeholders showing up where there's images on the web version.

HazelSh commented 1 year ago

Solved. The adapter was calling utf8fromSoup twice sometimes. This calls addImgUrl twice, which fetches images and does the url rewrite to the internal ffdl- names. The first time, the image downloads and ends up in the book, renamed. The second time, the url is wrong, and the image download fails. It should be spotting the internal filenames getting used, I think -- there's detection code at https://github.com/JimmXinu/FanFicFare/blob/83a5c28d71ae787662bb04ed8b9512bc44f4f2be/fanficfare/story.py#L1575 -- but I'm not sure that's triggering.

The image file failing to download (the second time) then leads to the failedtoload messages in the book source, and no image showing.

I'm gonna rework the adapter to, uh, not do that. Give me a sec. .

HazelSh commented 1 year ago

pr created: https://github.com/JimmXinu/FanFicFare/pull/930 got it working fine locally with that story.

JimmXinu commented 1 year ago

I've put up test versions with this fix, thanks @HazelSh!

FYI, it looks like the first 'chapter', labeled 'Home' in this particular story is empty and the missing file0001.xhtml is just this story? (FFF silently discards empty chapters.)

A 'quick' check of the first three chapters of a randomly selected story showed it did have text in the first 'chapter', AKA 'Home' AKA file0001.xhtml. It also took 30+ minutes for all the images in just the first 3 chapters--I don't have time to do any more testing at that rate. (510 images? That's not a story--that's a movie.)

Jemeni11 commented 1 year ago

Solved. The adapter was calling utf8fromSoup twice sometimes. This calls addImgUrl twice, which fetches images and does the url rewrite to the internal ffdl- names. The first time, the image downloads and ends up in the book, renamed. The second time, the url is wrong, and the image download fails.

Thanks @JimmXinu @HazelSh

A 'quick' check of the first three chapters of a randomly selected story showed it did have text in the first 'chapter', AKA 'Home' AKA file0001.xhtml. It also took 30+ minutes for all the images in just the first 3 chapters--I don't have time to do any more testing at that rate. (510 images? That's not a story--that's a movie.)

:laughing: :laughing: :laughing: