From 9bf42ff6c08d01eb4569a8d393c8a8931e6a0211 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Sun, 22 Feb 2026 04:56:25 +0100 Subject: [PATCH] Using API to fetch Aziani block IDs, fixed block IDs were incorrect interpretation. --- package-lock.json | 9 ++++---- package.json | 2 +- seeds/02_sites.js | 9 +------- src/scrapers/aziani.js | 50 ++++++++++++++++++++++++++++++++++++++---- 4 files changed, 53 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7af4db9e..300962b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -94,7 +94,7 @@ "tunnel": "0.0.6", "ua-parser-js": "^1.0.37", "undici": "^5.28.1", - "unprint": "^0.18.32", + "unprint": "^0.18.33", "url-pattern": "^1.0.3", "v-tooltip": "^2.1.3", "video.js": "^8.6.1", @@ -20385,9 +20385,10 @@ } }, "node_modules/unprint": { - "version": "0.18.32", - "resolved": "https://registry.npmjs.org/unprint/-/unprint-0.18.32.tgz", - "integrity": "sha512-3AOeu6vvAqJfxfYGJl/AUO07qnfFKbyyFpZzSBFwQJ+bZgU+kBX1uaj/4TD3ayBHkMgqRDYObJuGRQMZ6Xdncg==", + "version": "0.18.33", + "resolved": "https://registry.npmjs.org/unprint/-/unprint-0.18.33.tgz", + "integrity": "sha512-SCVWfYCou5aUXxJOFaG2LOmhRB+NO5ZxyO4gnpS2iUCb7vKpEgAqpgux5kL8AX0vg7Uhir8+X/Z4c/6tsLhUVQ==", + "license": "ISC", "dependencies": { "bottleneck": "^2.19.5", "cookie": "^1.1.1", diff --git a/package.json b/package.json index 0ddc6dc7..6ebc7491 100755 --- a/package.json +++ b/package.json @@ -153,7 +153,7 @@ "tunnel": "0.0.6", "ua-parser-js": "^1.0.37", "undici": "^5.28.1", - "unprint": "^0.18.32", + "unprint": "^0.18.33", "url-pattern": "^1.0.3", "v-tooltip": "^2.1.3", "video.js": "^8.6.1", diff --git a/seeds/02_sites.js b/seeds/02_sites.js index 1878a953..0c0ee619 100755 --- a/seeds/02_sites.js +++ b/seeds/02_sites.js @@ -1325,7 +1325,6 @@ const sites = [ seriesId: 268, // areaId: 3, areaId: '3b4c609c-6a0d-4cb9-9cce-0605f32b79ec', - blockId: 114458, scene: 'https://aziani.com', }, }, @@ -1338,9 +1337,7 @@ const sites = [ parameters: { // areaId: 2, areaId: '4f0a134f-8a1b-4bcb-8013-7e02fac4f61d', - blockId: 114064, seriesId: 107, - modelBlockId: 114129, }, }, { @@ -1351,10 +1348,9 @@ const sites = [ independent: true, parameters: { // areaId: 11, + videos: '/creampiled-videos', areaId: '29c61dae-db14-419b-93a4-d016b928dee9', - blockId: 115990, seriesId: 436, - modelBlockId: 115345, }, }, { @@ -1366,7 +1362,6 @@ const sites = [ parameters: { // areaId: 8, areaId: 'ae0a26fe-7f08-433d-bb04-a9b6f358c48e', - blockId: 116531, seriesId: 395, }, }, @@ -1378,7 +1373,6 @@ const sites = [ parameters: { // areaId: 3, areaId: '3b4c609c-6a0d-4cb9-9cce-0605f32b79ec', - blockId: 114458, seriesId: 105, scene: 'https://aziani.com', }, @@ -1392,7 +1386,6 @@ const sites = [ parameters: { // areaId: 3, areaId: '3b4c609c-6a0d-4cb9-9cce-0605f32b79ec', - blockId: 114458, seriesId: 106, scene: 'https://aziani.com', }, diff --git a/src/scrapers/aziani.js b/src/scrapers/aziani.js index 8185560f..caf0df10 100755 --- a/src/scrapers/aziani.js +++ b/src/scrapers/aziani.js @@ -71,10 +71,32 @@ function scrapeScene(data, channel, parameters) { return release; } +async function getBlockId(slug, dataSource, entity, parameters) { + const res = await unprint.get(`https://azianistudios.com/tour_api.php/content/page?slug=${slug}&data_source=${JSON.stringify(dataSource)}`, { + headers: { + Referer: entity.url, + 'x-nats-cms-area-id': parameters.areaId, + }, + }); + + if (res.ok && res.data.success) { + // unsure how the blocks differ exactly, but type set_view is missing directors for some reason + return res.data.blocks?.find((block) => ['navigation', 'html'].includes(block.settings.type))?.cms_block_id || null; + } + + return null; +} + async function fetchLatest(channel, page = 1, { parameters }) { + const blockId = await getBlockId(parameters.videos || '/videos', { page }, channel, parameters); + + if (!blockId) { + return null; + } + const query = new URLSearchParams({ cms_area_id: parameters.areaId, - cms_block_id: parameters.blockId, + cms_block_id: blockId, count: 100, start: (page - 1) * 100, orderby: 'published_desc', @@ -106,10 +128,20 @@ async function fetchLatest(channel, page = 1, { parameters }) { async function fetchScene(url, entity, _baseRelease, { parameters }) { const entryId = new URL(url).pathname.match(/\/video\/(\w+)/)[1]; + if (!entryId) { + return null; + } + + const blockId = await getBlockId('/video/:id', entryId, entity, parameters); + + if (!blockId) { + return null; + } + const query = new URLSearchParams({ cms_set_ids: entryId, cms_area_id: parameters.areaId, - cms_block_id: parameters.blockId, + cms_block_id: blockId, content: 1, orderby: 'published_desc', content_type: 'video', @@ -172,7 +204,7 @@ function scrapeProfile(data, entity, parameters) { return profile; } -async function fetchProfile({ url }, { entity, parameters }) { +async function fetchProfile({ name, url }, { entity, parameters }) { if (!url) { // no easy search option return null; @@ -180,9 +212,19 @@ async function fetchProfile({ url }, { entity, parameters }) { const actorId = new URL(url).pathname.match(/model\/(\d+)/)[1]; + if (!actorId) { + return null; + } + + const blockId = await getBlockId('/model/:id', { models: name, id: actorId }, entity, parameters); + + if (!blockId) { + return null; + } + const query = new URLSearchParams({ cms_data_value_ids: actorId, - cms_block_id: entity.parameters.modelBlockId || entity.parameters.blockId, + cms_block_id: blockId, cms_data_type_id: 4, }).toString();