Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ecau): add Booth.pm provider #663

Merged
merged 5 commits into from
Apr 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The following table describes the types of links supported by MB: Upload to CAA
| Audiomack | ✔️ | ✔️ | Doesn't check for track images, these may be singles.
| Bandcamp | ✔️ | ✔️ | Grabs custom track images. For non-square covers, a square thumbnail will be added too. Custom domains currently not supported. |
| Beatport | ✔️ | ✔️ | Beware of upscales. 1400x1400 on older releases is probably upscaled. |
| Booth | ✔ | ❌ | Types only filled for the first image. Note that Booth also contains products that aren't music albums (comics, stickers, etc.). |
| Bugs! | ✔️ | ✔️ |
| DatPiff | ✔️ | ✔️ |
| Deezer | ✔️ | ✔️ |
Expand Down
41 changes: 41 additions & 0 deletions src/mb_enhanced_cover_art_uploads/providers/booth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { ArtworkTypeIDs } from '@lib/MB/CoverArt';
import { assertDefined } from '@lib/util/assert';
import { safeParseJSON } from '@lib/util/json';

import type { CoverArt } from '../types';
import { CoverArtProvider } from './base';

interface BoothAPIInformation {
id: number;
images: Array<{
original: string;
resized: string;
caption: string | null; // TODO: Can we do something with this?
}>;
}

export class BoothProvider extends CoverArtProvider {
public readonly supportedDomains = ['*.booth.pm'];
public readonly favicon = 'https://booth.pm/static-images/pwa/icon_size_96.png';
public readonly name = 'Booth';
protected readonly urlRegex = /items\/(\d+)/;

public async findImages(url: URL): Promise<CoverArt[]> {
const itemId = this.extractId(url);
assertDefined(itemId);
const apiJson = await this.fetchPage(this.createApiUrl(itemId));
const apiData = safeParseJSON<BoothAPIInformation>(apiJson, 'Failed to parse Booth API response');
const covers: CoverArt[] = apiData.images.map((img) => ({ url: new URL(img.original) }));

if (covers.length > 0) {
// Assume first image is front cover.
covers[0].types = [ArtworkTypeIDs.Front];
}

return covers;
}

private createApiUrl(itemId: string): URL {
return new URL(`https://booth.pm/en/items/${itemId}.json`);
}
}
2 changes: 2 additions & 0 deletions src/mb_enhanced_cover_art_uploads/providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ArchiveProvider } from './archive';
import { AudiomackProvider } from './audiomack';
import { BandcampProvider } from './bandcamp';
import { BeatportProvider } from './beatport';
import { BoothProvider } from './booth';
import { BugsProvider } from './bugs';
import { DatPiffProvider } from './datpiff';
import { DeezerProvider } from './deezer';
Expand Down Expand Up @@ -44,6 +45,7 @@ addProvider(new ArchiveProvider());
addProvider(new AudiomackProvider());
addProvider(new BandcampProvider());
addProvider(new BeatportProvider());
addProvider(new BoothProvider());
addProvider(new BugsProvider());
addProvider(new CoverArtArchiveProvider());
addProvider(new DatPiffProvider());
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
WARC/1.1
WARC-Filename: booth provider/extracting images/extracts covers for album with one image
WARC-Date: 2023-04-23T08:03:06.915Z
WARC-Type: warcinfo
WARC-Record-ID: <urn:uuid:143d56b4-a0d7-413e-91f8-82220f4d6dbb>
Content-Type: application/warc-fields
Content-Length: 119

software: warcio.js
harVersion: 1.2
harCreator: {"name":"Polly.JS","version":"6.0.5","comment":"persister:fs-warc"}


WARC/1.1
WARC-Concurrent-To: <urn:uuid:c8bebdfb-a5b9-4463-8731-671cad060cdc>
WARC-Target-URI: https://booth.pm/en/items/2969400.json
WARC-Date: 2023-04-23T08:03:06.916Z
WARC-Type: request
WARC-Record-ID: <urn:uuid:b3ab9286-5cb2-464e-ad33-c95b85fe214a>
Content-Type: application/http; msgtype=request
WARC-Payload-Digest: sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
WARC-Block-Digest: sha256:3cdb8209bdf34c8feda2eb7dcccd503e47ea16f1a8894a8dc8000f621fe6cc21
Content-Length: 39

GET /en/items/2969400.json HTTP/1.1



WARC/1.1
WARC-Concurrent-To: <urn:uuid:c8bebdfb-a5b9-4463-8731-671cad060cdc>
WARC-Target-URI: https://booth.pm/en/items/2969400.json
WARC-Date: 2023-04-23T08:03:06.916Z
WARC-Type: metadata
WARC-Record-ID: <urn:uuid:ece0391c-d4cf-44bd-8064-16bf47dfb038>
Content-Type: application/warc-fields
WARC-Payload-Digest: sha256:17caea15f4d304ebf85db1dd98fca1a382dd03e7fe87512737121e1d5e94fd73
WARC-Block-Digest: sha256:17caea15f4d304ebf85db1dd98fca1a382dd03e7fe87512737121e1d5e94fd73
Content-Length: 1192

harEntryId: 822c484ad12a96d4448d3bbeee020c9c
harEntryOrder: 0
cache: {}
startedDateTime: 2023-04-23T08:03:05.629Z
time: 1280
timings: {"blocked":-1,"dns":-1,"connect":-1,"send":0,"wait":1280,"receive":0,"ssl":-1}
warcRequestHeadersSize: 57
warcRequestCookies: []
warcResponseHeadersSize: 3020
warcResponseCookies: [{"name":"recent_items","value":"2969400","domain":".booth.pm","path":"/","expires":"2023-04-23T08:33:07.000Z","secure, _plaza_session_nktz7u":"GcX2B88jozErHRX%2BYwiFWhhIGvr0TYQyPa2lbLyJd6sds3x0RjAMC8CMRXlNc%2BqlFwc4Wya%2Fa6z69BLgB8cI2Cb%2FFrk%2F%2FKhxkICQY67v8kQcs5HIe7bbkLhoHKn%2BuNMz5GsaVgTnTgD8utA%2BKGveURmqEYsVorsC9w%2By5cS9JKSu1mhdOvflogS2js07fYbv3A3FCd6bfWyW2v5TMmrTigc6bNqIK%2BPkWGj3K8q6iCHCD8i6xkF4Mt%2BOJYT63iiP3L6h40dI8DzgQqD%2Be3j8CO5MqNgB%2FCw9WHnunhLmlrN8E86k5tIewU3Bg2lGHLCF74LXzKNbWSfLBA1r7ShpEtF3O7tvYG4GBAHvMWpFY4WnLRFUI3ns3UHLUgyg3x4wDiDWcMmzhz39g%2Ff3f3Qf--H1O7mJD2K2xP6PHf--TTDVRmNUxjmZxzhEVXFt5Q%3D%3D","secure":true,"httponly, __cf_bm":"gfXE18ranULzwZPI4Yjdgw7qvvtjD2K9CVRXjms3cgE-1682236987-0-AXD1WtFN4gr9QgJ/VVveJI8ThOGWmIfvlVOMeLeJ/KMGR3pj8QPRH2N0lJP/cNsxu9BDlAIhWTZZIt99rLAsLio=","httpOnly":true,"sameSite":"None"}]
responseDecoded: false


WARC/1.1
WARC-Target-URI: https://booth.pm/en/items/2969400.json
WARC-Date: 2023-04-23T08:03:06.915Z
WARC-Type: response
WARC-Record-ID: <urn:uuid:c8bebdfb-a5b9-4463-8731-671cad060cdc>
Content-Type: application/http; msgtype=response
WARC-Payload-Digest: sha256:3fd6a1b2fcee33c6d46ed3194e7455df55285a8c9d7588282c492681e400605c
WARC-Block-Digest: sha256:35d97fc6ab15a7f626d40414209cbf550976eeea2b5e75a7be4dd57fd20bec74
Content-Length: 9360

HTTP/1.1 200 OK
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
cache-control: max-age=0, private, must-revalidate
cf-cache-status: DYNAMIC
cf-ray: 7bc496899d5eb97a-AMS
connection: close
content-encoding: gzip
content-language: en
content-security-policy: script-src 'strict-dynamic' 'unsafe-eval' 'unsafe-inline' https: 'report-sample' 'nonce-iYT1x2/1wKYSLcE1mHwcw99Nxhkq7g2TLUHQ/rE4syw='; object-src 'none'; base-uri 'self'; frame-src player.vimeo.com w.soundcloud.com www.slideshare.net www.youtube.com bandcamp.com sketchfab.com *.google.com *.facebook.com *.facebook.net *.twitter.com social-plugins.line.me *.g.doubleclick.net www.googletagmanager.com booth.karakuri.ai manage-booth.karakuri.ai point.widget.rakuten.co.jp hub.vroid.com ext.nicovideo.jp www.recaptcha.net https://booth.pm https://*.booth.pm https://factory.pixiv.net https://booth.pximg.net https://connect.buyee.jp https://www.googletagmanager.com; connect-src 'self' data: *.pixiv.net *.pawoo.net www.google-analytics.com analytics.google.com www.facebook.com connect.facebook.net www.googletagmanager.com www.googleadservices.com www.google.co.jp b92.yahoo.co.jp *.buyee.jp d.line-scdn.net stats.g.doubleclick.net ekr.zdassets.com *.zendesk.com errortrace.dev https://booth.pm https://*.booth.pm https://factory.pixiv.net https://booth.pximg.net https://connect.buyee.jp https://www.googletagmanager.com; report-uri https://errortrace.dev/api/34/security/?sentry_key=257cb7e4ddeb4cfdb29279c839542cb5
content-type: application/json; charset=utf-8
date: Sun, 23 Apr 2023 08:03:07 GMT
etag: W/"3fd6a1b2fcee33c6d46ed3194e7455df"
referrer-policy: strict-origin-when-cross-origin
server: cloudflare
set-cookie: recent_items=2969400; domain=.booth.pm; path=/; expires=Thu, 23 Apr 2043 08:03:06 GMT; secure, _plaza_session_nktz7u=GcX2B88jozErHRX%2BYwiFWhhIGvr0TYQyPa2lbLyJd6sds3x0RjAMC8CMRXlNc%2BqlFwc4Wya%2Fa6z69BLgB8cI2Cb%2FFrk%2F%2FKhxkICQY67v8kQcs5HIe7bbkLhoHKn%2BuNMz5GsaVgTnTgD8utA%2BKGveURmqEYsVorsC9w%2By5cS9JKSu1mhdOvflogS2js07fYbv3A3FCd6bfWyW2v5TMmrTigc6bNqIK%2BPkWGj3K8q6iCHCD8i6xkF4Mt%2BOJYT63iiP3L6h40dI8DzgQqD%2Be3j8CO5MqNgB%2FCw9WHnunhLmlrN8E86k5tIewU3Bg2lGHLCF74LXzKNbWSfLBA1r7ShpEtF3O7tvYG4GBAHvMWpFY4WnLRFUI3ns3UHLUgyg3x4wDiDWcMmzhz39g%2Ff3f3Qf--H1O7mJD2K2xP6PHf--TTDVRmNUxjmZxzhEVXFt5Q%3D%3D; domain=.booth.pm; path=/; expires=Tue, 23 Apr 2024 08:03:06 GMT; secure; HttpOnly, __cf_bm=gfXE18ranULzwZPI4Yjdgw7qvvtjD2K9CVRXjms3cgE-1682236987-0-AXD1WtFN4gr9QgJ/VVveJI8ThOGWmIfvlVOMeLeJ/KMGR3pj8QPRH2N0lJP/cNsxu9BDlAIhWTZZIt99rLAsLio=; path=/; expires=Sun, 23-Apr-23 08:33:07 GMT; domain=.booth.pm; HttpOnly; Secure; SameSite=None
strict-transport-security: max-age=63072000; includeSubDomains
transfer-encoding: chunked
vary: Origin
x-content-type-options: nosniff
x-download-options: noopen
x-frame-options: SAMEORIGIN
x-permitted-cross-domain-policies: none
x-request-id: 99f41522-8fb7-4a9d-938f-9a5dc63bebcd
x-runtime: 0.215211
x-xss-protection: 1; mode=block
x-pollyjs-finalurl: https://booth.pm/en/items/2969400.json

{"description":"【ダウンロード音源付き!!】\n\n【送料応援特別価格 ¥2,750→¥2,500】\n\n「それでも、愛。」\n\nまっすぐな愛、いびつな愛、ありふれた愛。\n5thアルバムとなる本作『ラヴ』は、人類愛などマクロな視点から「愛」を描くことが多かったピノキオピーが、息苦しいまでの「正しさ」で溢れ、分断が加速する社会の中で日々生まれる、さまざまな「愛」に焦点を当てた意欲作。\n\n前作『零号』の艶のあるエレクトロサウンドを更に深化させ、余計な情報を削ぎ落とした、ビートの輪郭が際立つメロディアスかつソリッドな作品に仕上がっている。\n\nTikTokで2億回以上再生されている「推し」への恋心を描いた『ラヴィット』、不器用な自己愛を綴った『アルティメットセンパイ』など、正解のない感情を肯定するでも否定するでもなく、ピノキオピーは、確かにそこに存在する「愛」を謡う。\n\n収録楽曲は、動画共有サイトへ投稿した人気楽曲を含む12曲入り。公開動画の累計再生回数は1,800万回を超えている(2021年5月現在)。\n\nころんへの提供楽曲『404』、スマホゲーム「#コンパス 戦闘摂理解析システム」書き下ろし楽曲『リアルにぶっとばす』に加え、スマホゲーム「プロジェクトセカイ」書き下ろし楽曲『セカイはまだ始まってすらいない』、マジカルミライ2020テーマソング『愛されなくても君がいる』のセルフリミックスver.を収録。","factory_description":null,"id":2969400,"is_adult":false,"is_buyee_possible":true,"is_end_of_sale":false,"is_placeholder":false,"is_sold_out":false,"name":"ラヴ","price":"2,500 JPY","purchase_limit":null,"shipping_info":"Ships within 7 days","small_stock":null,"url":"https://pinocchiop.booth.pm/items/2969400","wish_list_url":"https://booth.pm/items/2969400/wish_list","wish_lists_count":709,"wished":false,"buyee_variations":[{"buyee_html":"\u003ciframe src=\"https://connect.buyee.jp/booth/iframe_button.html?bgcolor=%23FF5c67\u0026amp;code=4900797\u0026amp;fontcolor=%23FFFFFF\u0026amp;image=https%3A%2F%2Fbooth.pximg.net%2Fd7c1a1c3-4d48-4540-ae47-17a7829e5bc6%2Fi%2F2969400%2Fcb2b3f79-e5d1-4186-811f-229bc4a8cdad_base_resized.jpg\u0026amp;is_limited=false\u0026amp;price=2500\u0026amp;seller=%E3%83%94%E3%83%8E%E3%82%AD%E3%82%AA%E3%83%94%E3%83%BC+%2F+PinocchioP+Official+Shop\u0026amp;seller_id=d7c1a1c3-4d48-4540-ae47-17a7829e5bc6\u0026amp;style=booth1\u0026amp;text=Add+to+Buyee+Cart\u0026amp;title=%E3%83%A9%E3%83%B4\u0026amp;url=https%3A%2F%2Fbooth.pm%2Fja%2Fitems%2F2969400\u0026amp;variations=default\" height=\"60px\" width=\"100%\" style=\"border:0;\"\u003e\u003c/iframe\u003e","downloadable":null,"factory_image_url":null,"has_download_code":false,"id":4900797,"is_anshin_booth_pack":false,"is_empty_allocatable_stock_with_preorder":false,"is_empty_stock":false,"is_factory_item":false,"is_mailbin":true,"is_waiting_on_arrival":false,"name":null,"order_url":null,"price":2500,"small_stock":null,"status":"addable_to_cart","type":"via_warehouse"}],"category":{"id":35,"name":"Vocaloid","parent":{"name":"Music","url":"https://booth.pm/en/browse/Music"},"url":"https://booth.pm/en/browse/Vocaloid"},"embeds":[],"images":[{"caption":null,"original":"https://booth.pximg.net/d7c1a1c3-4d48-4540-ae47-17a7829e5bc6/i/2969400/cb2b3f79-e5d1-4186-811f-229bc4a8cdad_base_resized.jpg","resized":"https://booth.pximg.net/c/72x72_a2_g5/d7c1a1c3-4d48-4540-ae47-17a7829e5bc6/i/2969400/cb2b3f79-e5d1-4186-811f-229bc4a8cdad_base_resized.jpg"}],"order":null,"share":{"hashtags":["booth_pm"],"text":"ラヴ | ピノキオピー / PinocchioP Official Shop"},"shop":{"name":"ピノキオピー / PinocchioP Official Shop","subdomain":"pinocchiop","thumbnail_url":"https://booth.pximg.net/c/48x48/users/141387/icon_image/b5541a0d-a768-4e01-beac-07c3abaf578c_base_resized.jpg","url":"https://pinocchiop.booth.pm/","verified":false},"sound":null,"tags":[{"name":"VOCALOID","url":"https://booth.pm/en/items?tags%5B%5D=VOCALOID"},{"name":"Hatsune Miku","url":"https://booth.pm/en/items?tags%5B%5D=Hatsune+Miku"},{"name":"ピノキオピー","url":"https://booth.pm/en/items?tags%5B%5D=%E3%83%94%E3%83%8E%E3%82%AD%E3%82%AA%E3%83%94%E3%83%BC"}],"tag_banners":[{"image_url":"https://booth.pximg.net/c/150x150/01b481cf-ad99-42e7-91a6-1b2361828496/i/277127/751eacdc-04be-454c-91d5-07e69b8e184f_base_resized.jpg","name":"VOCALOID","url":"https://booth.pm/en/items?tags%5B%5D=VOCALOID"},{"image_url":"https://booth.pximg.net/c/150x150/d7c1a1c3-4d48-4540-ae47-17a7829e5bc6/i/177668/cb5d56c9-de84-4914-8007-3c8cd3ee5d64_base_resized.jpg","name":"Hatsune Miku","url":"https://booth.pm/en/items?tags%5B%5D=Hatsune+Miku"},{"image_url":null,"name":"ピノキオピー","url":"https://booth.pm/en/items?tags%5B%5D=%E3%83%94%E3%83%8E%E3%82%AD%E3%82%AA%E3%83%94%E3%83%BC"}],"tag_combination":{"category":"Vocaloid","tag":"VOCALOID","url":"https://booth.pm/en/browse/Vocaloid?tags%5B%5D=VOCALOID"},"tracks":null,"variations":[{"buyee_html":"\u003ciframe src=\"https://connect.buyee.jp/booth/iframe_button.html?bgcolor=%23FF5c67\u0026amp;code=4900797\u0026amp;fontcolor=%23FFFFFF\u0026amp;image=https%3A%2F%2Fbooth.pximg.net%2Fd7c1a1c3-4d48-4540-ae47-17a7829e5bc6%2Fi%2F2969400%2Fcb2b3f79-e5d1-4186-811f-229bc4a8cdad_base_resized.jpg\u0026amp;is_limited=false\u0026amp;price=2500\u0026amp;seller=%E3%83%94%E3%83%8E%E3%82%AD%E3%82%AA%E3%83%94%E3%83%BC+%2F+PinocchioP+Official+Shop\u0026amp;seller_id=d7c1a1c3-4d48-4540-ae47-17a7829e5bc6\u0026amp;style=booth1\u0026amp;text=Add+to+Buyee+Cart\u0026amp;title=%E3%83%A9%E3%83%B4\u0026amp;url=https%3A%2F%2Fbooth.pm%2Fja%2Fitems%2F2969400\u0026amp;variations=default\" height=\"60px\" width=\"100%\" style=\"border:0;\"\u003e\u003c/iframe\u003e","downloadable":null,"factory_image_url":null,"has_download_code":false,"id":4900797,"is_anshin_booth_pack":false,"is_empty_allocatable_stock_with_preorder":false,"is_empty_stock":false,"is_factory_item":false,"is_mailbin":true,"is_waiting_on_arrival":false,"name":null,"order_url":null,"price":2500,"small_stock":null,"status":"addable_to_cart","type":"via_warehouse"}]}

Loading