Using API to fetch Aziani block IDs, fixed block IDs were incorrect interpretation.
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user