scrobble-moe / AniList.bundle

AniList Metadata provider for Plex
GNU General Public License v3.0
31 stars 3 forks source link

HTML escaped characters in summary #4

Closed dr-dialup closed 3 years ago

dr-dialup commented 3 years ago

Seems like if there are HTML escaped characters in a description on AniList, they don't get unescaped when put into the summary on Plex. Not sure why some descriptions have them to begin with, but it's kind of annoying.

Example:

From Aoi Hana AniList page

In the original manga’s story, Fumi and Akira were close childhood friends until Fumi had to move away. Ten years after losing touch with each other, the two girls meet again as high school freshmen. The two struggle to reconnect after so much has changed, and both deal with the trials and tribulations of high school — sometimes independently and sometimes with each other’s help.

(Source: Anime News Network)

From Aoi Hana AniList edit page:

In the original manga&rsquo;s story, Fumi and Akira were close childhood friends until Fumi had to move away. Ten years after losing touch with each other, the two girls meet again as high school freshmen. The two struggle to reconnect after so much has changed, and both deal with the trials and tribulations of high school &mdash; sometimes independently and sometimes with each other&rsquo;s help.<br><br>
(Source: Anime News Network)

From Aoi Hana summary from Plex:

In the original manga&rsquo;s story, Fumi and Akira were close childhood friends until Fumi had to move away. Ten years after losing touch with each other, the two girls meet again as high school freshmen. The two struggle to reconnect after so much has changed, and both deal with the trials and tribulations of high school &mdash; sometimes independently and sometimes with each other&rsquo;s help.

(Source: Anime News Network)
sachaw commented 3 years ago

I'll try to take a look, but I'm no python expert, so feel free to suggest a solution if you find one.

dr-dialup commented 3 years ago

My Python is near non-existent, but I was able to get it to render properly by referring to this StackOverflow page.

from datetime import datetime
from providers import get_anime, get_episodes
import certifi
from utils import requests_retry_session
import re
import base64
try:
    # Python 2.6-2.7
    from HTMLParser import HTMLParser
except ImportError:
    # Python 3
    from html.parser import HTMLParser
# Summary
    if metadata.summary is None or force:
        try:
            h = HTMLParser()
            cleanr = re.compile('<.*?>')
            metadata.summary = re.sub(cleanr, '', h.unescape(anime['description']))
        except:
            Log.Error('Error: Show has no summary: ' + metadata.id)
sachaw commented 3 years ago

Massive thanks, Now released in V2.7