evazion / translate-pixiv-tags

MIT License
35 stars 6 forks source link

update site rules for artist profile pages #99

Closed hdk5 closed 3 days ago

hdk5 commented 3 days ago

Add new icons, add new domain rules, remove superfluous domain rules automatically handled by getSiteName

7nik commented 3 days ago

I wonder if we can drop all those icon resources by doing something like

const SITE_ICON_FOLDER = "https://raw.githubusercontent.com/danbooru/danbooru/22e1b4d3bf0a8776dbac282f4e3a83d62facc537/public/images/";
function getSiteIconUrl (siteName) {
    return getImage(`${SITE_ICON_FOLDER}${siteName.toLowerCase().replaceAll(/[^\w.]/g, "-")}-logo.png`);
}
const getSiteIconUrlMemoized = _.memoize(getSiteIconUrl, memoizeKey);

plus check for the site being in the SITE_RULES. And adjust the code for the async loading of icons, like in buildPostPreview.

hdk5 commented 3 days ago

It is possible if icons might not be loaded initially is not an issue. Well, the browser will probably just cache them anyways. Don't really understand why use async loading hack for this tho.

7nik commented 3 days ago

Due to CSP, they won't load on Twitter and a few other sites, and you cannot convert a link to a CSP-friendly one synchronically.

hdk5 commented 1 day ago

Oh, right, I forgot that Twitter does that. But it should work in either case, yeah. Do however you see best.

Also, forgot to add that I noticed a bit of a mess in the main danbooru repo - there are sites defined both in null and own extractor, and some artist urls on the main instance are not normalized to their most recent normal forms (per Source::URL.profile_url). Can't really be arsed to fix those myself, so I'll just let @nonamethanks know.

nonamethanks commented 23 hours ago

Do you have a list of urls that need fixing? I can cook up a mass fixing script via api.

hdk5 commented 20 hours ago

Nah. I were just checking some random artists that has new supported sites, and I remember there were some urls that do not match what profile_url method would produce, but I didn't note which ones specifically are like that. I guess all those added after a certain commit could be checked?

$ git log --name-only --format="" --diff-filter=A ab00f43..HEAD -- app/logical/source/url
app/logical/source/url/pixellent.rb app/logical/source/url/pixiv_factory.rb app/logical/source/url/kofi.rb app/logical/source/url/kakao.rb app/logical/source/url/tistory.rb app/logical/source/url/grafolio.rb app/logical/source/url/miyoushe.rb app/logical/source/url/skland.rb app/logical/source/url/toyhouse.rb app/logical/source/url/naver_cafe.rb app/logical/source/url/carrd.rb app/logical/source/url/redgifs.rb app/logical/source/url/url_shortener.rb app/logical/source/url/bcy.rb app/logical/source/url/google.rb app/logical/source/url/youtube.rb app/logical/source/url/vk.rb app/logical/source/url/blogger.rb app/logical/source/url/patreon.rb app/logical/source/url/xiaohongshu.rb app/logical/source/url/naver_post.rb app/logical/source/url/naver_blog.rb app/logical/source/url/pixiv_comic.rb app/logical/source/url/note.rb app/logical/source/url/my_portfolio.rb app/logical/source/url/piapro.rb app/logical/source/url/cohost.rb app/logical/source/url/behance.rb app/logical/source/url/opensea.rb app/logical/source/url/discord.rb app/logical/source/url/dotpict.rb app/logical/source/url/galleria.rb app/logical/source/url/artistree.rb app/logical/source/url/postype.rb app/logical/source/url/itaku.rb app/logical/source/url/foriio.rb app/logical/source/url/pinterest.rb app/logical/source/url/danbooru2.rb app/logical/source/url/bluesky.rb