From 18b219850e3be9a033b6a782153511e6d83dab37 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Thu, 31 Mar 2022 14:11:13 +0200 Subject: [PATCH] Storing scene qualities. Updated Perv City scraper. --- assets/components/releases/release.vue | 23 +++++++++++++++++++++++ assets/js/fragments.js | 2 ++ migrations/20220331135618_qualities.js | 7 +++++++ migrations/_20220330230122_stats.js | 12 ++++++++++++ src/scrapers/pervcity.js | 12 +++++++++++- src/store-releases.js | 7 +++---- 6 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 migrations/20220331135618_qualities.js create mode 100644 migrations/_20220330230122_stats.js diff --git a/assets/components/releases/release.vue b/assets/components/releases/release.vue index 17b73150..b077d800 100644 --- a/assets/components/releases/release.vue +++ b/assets/components/releases/release.vue @@ -203,6 +203,19 @@ +
+ Available qualities + + {{ quality }} +
+
knex.schema.alterTable('releases', (table) => { + table.specificType('qualities', 'text[]'); +}); + +exports.down = async (knex) => knex.schema.alterTable('releases', (table) => { + table.dropColumn('qualities'); +}); diff --git a/migrations/_20220330230122_stats.js b/migrations/_20220330230122_stats.js new file mode 100644 index 00000000..02b81a71 --- /dev/null +++ b/migrations/_20220330230122_stats.js @@ -0,0 +1,12 @@ +exports.up = async (knex) => knex.raw(` + CREATE MATERIALIZED VIEW entities_stats + AS + SELECT entities.id AS entity_id, count(releases.id) AS releases_count + FROM entities + LEFT JOIN releases ON releases.entity_id = entities.id + GROUP BY entities.id; +`); + +exports.down = async (knex) => knex.raw(` + DROP MATERIALIZED VIEW entities_stats; +`); diff --git a/src/scrapers/pervcity.js b/src/scrapers/pervcity.js index 5ab48803..bbe44c4e 100644 --- a/src/scrapers/pervcity.js +++ b/src/scrapers/pervcity.js @@ -12,6 +12,13 @@ const channelCodes = { uha: 'upherasshole', }; +const qualities = { + v4k: 2160, + vFullHD: 1080, + vHD: 720, + vSD: 480, +}; + const channelRegExp = new RegExp(Object.keys(channelCodes).join('|'), 'i'); function scrapeAll(scenes, entity) { @@ -42,9 +49,12 @@ function scrapeScene({ query }) { release.entryId = query.q('.trailerLeft img', 'id').match(/set-target-(\d+)/)[1]; release.title = query.cnt('.infoHeader h1'); - release.description = query.cnt('.infoBox p'); + release.description = query.cnt('.description'); + release.duration = query.duration('.tRuntime'); release.actors = query.cnts('.infoBox .tour_update_models a'); + release.tags = query.cnts('.tagcats a'); + release.qualities = query.imgs('.avaiFormate img').map((src) => qualities[src.match(/\/(\w+)\.png/)[1]]).filter(Boolean); release.poster = query.img('.posterimg'); release.photos = query.imgs('.trailerSnaps img').slice(1); // first photo is poster in lower quality diff --git a/src/store-releases.js b/src/store-releases.js index f51fab83..82a80974 100644 --- a/src/store-releases.js +++ b/src/store-releases.js @@ -38,11 +38,8 @@ async function curateReleaseEntry(release, batchId, existingRelease, type = 'sce date_precision: release.datePrecision, slug, description: release.description, + qualities: release.qualities.map(Number).filter(Boolean), comment: release.comment, - // director: release.director, - // likes: release.rating && release.rating.likes, - // dislikes: release.rating && release.rating.dislikes, - // rating: release.rating && release.rating.stars && Math.floor(release.rating.stars), deep: typeof release.deep === 'boolean' ? release.deep : false, deep_url: release.deepUrl, updated_batch_id: batchId, @@ -72,6 +69,8 @@ async function curateReleaseEntry(release, batchId, existingRelease, type = 'sce curatedRelease.created_batch_id = batchId; } + console.log(curatedRelease); + return curatedRelease; }