forked from DebaucheryLibrarian/traxxx
Added release page with photo viewer. Added photo count to database. Improved styling.
This commit is contained in:
@@ -87,13 +87,16 @@ async function storeReleases(releases = []) {
|
||||
title: release.title,
|
||||
date: release.date,
|
||||
description: release.description,
|
||||
director: release.director,
|
||||
// director: release.director,
|
||||
duration: release.duration,
|
||||
photos: release.photos ? release.photos.length : 0,
|
||||
likes: release.rating && release.rating.likes,
|
||||
dislikes: release.rating && release.rating.dislikes,
|
||||
rating: release.rating && release.rating.stars,
|
||||
};
|
||||
|
||||
console.log(`Storing (${release.site.name}, ${release.id}) "${release.title}"`);
|
||||
|
||||
const releaseQuery = `${knex('releases').insert(curatedRelease).toString()} ON CONFLICT DO NOTHING RETURNING *`;
|
||||
const releaseEntry = await knex.raw(releaseQuery);
|
||||
|
||||
@@ -117,15 +120,18 @@ async function storeReleases(releases = []) {
|
||||
})));
|
||||
}
|
||||
|
||||
if (release.thumbnails && release.thumbnails.length > 0) {
|
||||
const thumbnailPath = path.join(config.thumbnailPath, release.site.id, releaseEntry.rows[0].id.toString());
|
||||
if (release.photos && release.photos.length > 0) {
|
||||
const photoPath = path.join(config.photoPath, release.site.id, releaseEntry.rows[0].id.toString());
|
||||
|
||||
await fs.mkdir(thumbnailPath, { recursive: true });
|
||||
await fs.mkdir(photoPath, { recursive: true });
|
||||
|
||||
await Promise.map(release.thumbnails, async (thumbnailUrl, index) => {
|
||||
const res = await bhttp.get(thumbnailUrl);
|
||||
console.log(`Storing photos for (${release.site.name}, ${release.id}) "${release.title}"`);
|
||||
|
||||
await fs.writeFile(path.join(thumbnailPath, `${index}.jpg`), res.body);
|
||||
await Promise.map(release.photos, async (photoUrl, index) => {
|
||||
const res = await bhttp.get(photoUrl);
|
||||
await fs.writeFile(path.join(photoPath, `${index + 1}.jpg`), res.body);
|
||||
|
||||
return photoUrl;
|
||||
}, {
|
||||
concurrency: 2,
|
||||
});
|
||||
|
||||
@@ -82,14 +82,16 @@ async function storeRelease(release) {
|
||||
title: release.title,
|
||||
date: release.date,
|
||||
description: release.description,
|
||||
director: release.director,
|
||||
// director: release.director,
|
||||
duration: release.duration,
|
||||
photos: release.photos ? release.photos.length : 0,
|
||||
likes: release.rating && release.rating.likes,
|
||||
dislikes: release.rating && release.rating.dislikes,
|
||||
rating: release.rating && release.rating.stars,
|
||||
};
|
||||
|
||||
console.log('Saving releases to database');
|
||||
console.log('Saving release to database');
|
||||
|
||||
await knex.raw(`${knex('releases').insert(curatedRelease).toString()} ON CONFLICT (site_id, shoot_id) DO UPDATE SET
|
||||
description = EXCLUDED.description,
|
||||
likes = EXCLUDED.likes,
|
||||
|
||||
@@ -24,6 +24,7 @@ async function curateRelease(release) {
|
||||
actors,
|
||||
director: release.director,
|
||||
tags,
|
||||
photos: release.photos,
|
||||
rating: {
|
||||
likes: release.likes,
|
||||
dislikes: release.dislikes,
|
||||
|
||||
@@ -11,9 +11,9 @@ function scrapeLatest(html, site) {
|
||||
const scenesElements = $('.update_details').toArray();
|
||||
|
||||
return scenesElements.map((element) => {
|
||||
const thumbnailElement = $(element).find('a img.thumbs');
|
||||
const thumbnailCount = Number(thumbnailElement.attr('cnt'));
|
||||
const thumbnails = Array.from({ length: thumbnailCount }, (value, index) => thumbnailElement.attr(`src${index}_1x`)).filter(thumbnailUrl => thumbnailUrl !== undefined);
|
||||
const photoElement = $(element).find('a img.thumbs');
|
||||
const photoCount = Number(photoElement.attr('cnt'));
|
||||
const photos = Array.from({ length: photoCount }, (value, index) => photoElement.attr(`src${index}_1x`)).filter(photoUrl => photoUrl !== undefined);
|
||||
|
||||
const sceneLinkElement = $(element).children('a').eq(1);
|
||||
const url = sceneLinkElement.attr('href');
|
||||
@@ -36,7 +36,7 @@ function scrapeLatest(html, site) {
|
||||
actors,
|
||||
date,
|
||||
site,
|
||||
thumbnails,
|
||||
photos,
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -46,9 +46,9 @@ function scrapeUpcoming(html, site) {
|
||||
const scenesElements = $('#coming_soon_carousel').find('.table').toArray();
|
||||
|
||||
return scenesElements.map((element) => {
|
||||
const thumbnailElement = $(element).find('a img.thumbs');
|
||||
const thumbnailCount = Number(thumbnailElement.attr('cnt'));
|
||||
const thumbnails = Array.from({ length: thumbnailCount }, (value, index) => thumbnailElement.attr(`src${index}_1x`)).filter(thumbnailUrl => thumbnailUrl !== undefined);
|
||||
const photoElement = $(element).find('a img.thumbs');
|
||||
const photoCount = Number(photoElement.attr('cnt'));
|
||||
const photos = Array.from({ length: photoCount }, (value, index) => photoElement.attr(`src${index}_1x`)).filter(photoUrl => photoUrl !== undefined);
|
||||
|
||||
const shootId = $(element).find('.upcoming_updates_thumb').attr('id').match(/\d+/)[0];
|
||||
|
||||
@@ -77,7 +77,7 @@ function scrapeUpcoming(html, site) {
|
||||
title,
|
||||
date,
|
||||
actors,
|
||||
thumbnails,
|
||||
photos,
|
||||
rating: null,
|
||||
site,
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ function scrapeLatest(html, site) {
|
||||
const shootId = href.split('/')[2];
|
||||
const title = sceneLinkElement.text().trim();
|
||||
|
||||
const thumbnails = $(element).find('.rollover .roll-image').map((thumbnailIndex, thumbnailElement) => $(thumbnailElement).attr('data-imagesrc')).toArray();
|
||||
const photos = $(element).find('.rollover .roll-image').map((photoIndex, photoElement) => $(photoElement).attr('data-imagesrc')).toArray();
|
||||
|
||||
const date = moment.utc($(element).find('.date').text(), 'MMM DD, YYYY').toDate();
|
||||
const actors = $(element).find('.shoot-thumb-models a').map((actorIndex, actorElement) => $(actorElement).text()).toArray();
|
||||
@@ -35,7 +35,7 @@ function scrapeLatest(html, site) {
|
||||
title,
|
||||
actors,
|
||||
date,
|
||||
thumbnails,
|
||||
photos,
|
||||
rating: {
|
||||
stars,
|
||||
},
|
||||
@@ -52,7 +52,7 @@ async function scrapeScene(html, url, shootId, ratingRes, site) {
|
||||
const title = $('h1.shoot-title span.favorite-button').attr('data-title');
|
||||
const actorsRaw = $('.shoot-info p.starring');
|
||||
|
||||
const thumbnails = $('.gallery .thumb img').map((thumbnailIndex, thumbnailElement) => `https://cdnp.kink.com${$(thumbnailElement).attr('data-image-file')}`).toArray();
|
||||
const photos = $('.gallery .thumb img').map((photoIndex, photoElement) => `https://cdnp.kink.com${$(photoElement).attr('data-image-file')}`).toArray();
|
||||
const trailerVideo = $('.player span[data-type="trailer-src"]').attr('data-url');
|
||||
const trailerPoster = $('.player video#kink-player').attr('poster');
|
||||
|
||||
@@ -85,7 +85,7 @@ async function scrapeScene(html, url, shootId, ratingRes, site) {
|
||||
date,
|
||||
actors,
|
||||
description,
|
||||
thumbnails,
|
||||
photos,
|
||||
trailer: {
|
||||
video: {
|
||||
default: trailerVideo,
|
||||
|
||||
@@ -12,7 +12,7 @@ function initServer() {
|
||||
const app = express();
|
||||
const router = Router();
|
||||
|
||||
router.use(express.static(config.thumbnailPath));
|
||||
router.use(express.static(config.photoPath));
|
||||
router.use(express.static('public'));
|
||||
router.use(bodyParser.json({ strict: false }));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user