Skip to content

Recommended change to fix title issues on nhentai.net #2

@zeldatp151

Description

@zeldatp151

I only use this for nhentai.net so idk if this change would break things for other sites, but I kept having issues with bad outputs for the TITLE due to nhentai adding extra stuff in the <title>.*</title> field. I also had issue with some titles being too long with both the japanese and english titles included so this change makes it so that IF there is an english title, it only prints the english title, otherwise it prints the japanese title.

I simply replaced the folowing 2 lines

TITLE=$(echo "$html" | grep -o '<title>.*</title>' | sed 's/<title>//g' | sed 's/<\/title>//g' | sed 's/\///g')

echo "Title :- $(echo "$html" | grep -o '<title>.*</title>' | sed 's/<title>//g' | sed 's/<\/title>//g')"

with these

TITLE=$(echo "$html" | grep -o '<meta itemprop="name" content="[^"]*"' | sed -E 's/.*content="([^"]*)".*/\1/' | awk -F'|' '{if (NF>1) print $2; else print $1}')

echo "Title :- $(echo "$html" | grep -o '<meta itemprop="name" content="[^"]*"' | sed -E 's/.*content="([^"]*)".*/\1/' | awk -F'|' '{if (NF>1) print $2; else print $1}')" 

I hope this helps anyone else who had the same issues I did.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions