Scraping from Cherry Pimps when available. Showing cover in movie tile.
This commit is contained in:
parent
767437d9aa
commit
b4f0501765
|
@ -43,6 +43,6 @@ export default {
|
|||
|
||||
.tiles {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, 12rem);
|
||||
grid-template-columns: repeat(auto-fill, 15rem);
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -1,5 +1,19 @@
|
|||
<template>
|
||||
<div class="tile">
|
||||
<div class="cover">
|
||||
<img
|
||||
v-if="movie.covers[0]"
|
||||
:src="`/media/${movie.covers[0].thumbnail}`"
|
||||
class="front"
|
||||
>
|
||||
|
||||
<img
|
||||
v-if="movie.covers[1]"
|
||||
:src="`/media/${movie.covers[1].thumbnail}`"
|
||||
class="back"
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="details">{{ movie.entity.name }}</div>
|
||||
<h3 class="title">{{ movie.title }}</h3>
|
||||
</div>
|
||||
|
@ -18,8 +32,11 @@ export default {
|
|||
|
||||
<style lang="scss" scoped>
|
||||
.tile {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: var(--background);
|
||||
box-shadow: 0 0 3px var(--darken);
|
||||
font-size: 0;
|
||||
}
|
||||
|
||||
.details {
|
||||
|
@ -30,6 +47,26 @@ export default {
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
.cover {
|
||||
img {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.back {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
.back {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.front {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.title {
|
||||
padding: 1rem;
|
||||
margin: 0;
|
||||
|
|
|
@ -70,6 +70,13 @@ function initReleasesActions(store, _router) {
|
|||
name
|
||||
slug
|
||||
}
|
||||
covers: moviesCoversByReleaseId {
|
||||
media {
|
||||
id
|
||||
path
|
||||
thumbnail
|
||||
}
|
||||
}
|
||||
}
|
||||
totalCount
|
||||
}
|
||||
|
|
|
@ -644,7 +644,7 @@ exports.up = knex => Promise.resolve()
|
|||
.defaultTo(knex.fn.now());
|
||||
}))
|
||||
.then(() => knex.schema.createTable('movies_covers', (table) => {
|
||||
table.integer('movie_id', 16)
|
||||
table.integer('release_id', 16)
|
||||
.notNullable()
|
||||
.references('id')
|
||||
.inTable('movies');
|
||||
|
@ -654,7 +654,7 @@ exports.up = knex => Promise.resolve()
|
|||
.references('id')
|
||||
.inTable('media');
|
||||
|
||||
table.unique(['movie_id', 'media_id']);
|
||||
table.unique(['release_id', 'media_id']);
|
||||
}))
|
||||
.then(() => knex.schema.createTable('movies_trailers', (table) => {
|
||||
table.integer('movie_id', 16)
|
||||
|
|
|
@ -31,28 +31,34 @@ function scrapeAll(scenes, site) {
|
|||
}).filter(Boolean);
|
||||
}
|
||||
|
||||
function scrapeScene({ q, qd, qa }, url, _site, baseRelease) {
|
||||
function scrapeScene({ query, html }, url, _site, baseRelease) {
|
||||
const release = { url };
|
||||
|
||||
const { pathname } = new URL(url);
|
||||
release.entryId = pathname.match(/\/\d+/)[0].slice(1);
|
||||
|
||||
release.title = q('.trailer-block_title', true);
|
||||
release.description = q('.info-block:nth-child(3) .text', true);
|
||||
release.date = qd('.info-block_data .text', 'MMMM D, YYYY', /\w+ \d{1,2}, \d{4}/);
|
||||
release.title = query.q('.trailer-block_title', true);
|
||||
release.description = query.q('.info-block:nth-child(3) .text', true);
|
||||
release.date = query.date('.info-block_data .text', 'MMMM D, YYYY', /\w+ \d{1,2}, \d{4}/);
|
||||
|
||||
const duration = baseRelease?.duration || Number(q('.info-block_data .text', true).match(/(\d+)\s+min/)?.[1]) * 60;
|
||||
const duration = baseRelease?.duration || Number(query.q('.info-block_data .text', true).match(/(\d+)\s+min/)?.[1]) * 60;
|
||||
if (duration) release.duration = duration;
|
||||
|
||||
release.actors = qa('.info-block_data a[href*="/models"]', true);
|
||||
release.tags = qa('.info-block a[href*="/categories"]', true);
|
||||
release.actors = query.all('.info-block_data a[href*="/models"]', true);
|
||||
release.tags = query.all('.info-block a[href*="/categories"]', true);
|
||||
|
||||
const posterEl = q('.update_thumb');
|
||||
const poster = posterEl.getAttribute('src0_3x') || posterEl.getAttribute('src0_2x') || posterEl.dataset.src;
|
||||
const posterEl = query.q('.update_thumb');
|
||||
const poster = posterEl?.getAttribute('src0_3x') || posterEl?.getAttribute('src0_2x') || posterEl?.dataset.src;
|
||||
|
||||
if (poster && baseRelease?.poster) release.photos = [poster];
|
||||
else if (poster) release.poster = poster;
|
||||
|
||||
const trailer = html.match(/video src="(.*?)"/);
|
||||
|
||||
if (trailer) {
|
||||
release.trailer = trailer[1];
|
||||
}
|
||||
|
||||
return release;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,6 @@ function curateReleaseEntry(release, batchId, existingRelease, type = 'scene') {
|
|||
limit: config.titleSlugLength,
|
||||
});
|
||||
|
||||
console.log(release);
|
||||
|
||||
const curatedRelease = {
|
||||
title: release.title,
|
||||
entry_id: release.entryId || null,
|
||||
|
@ -47,7 +45,7 @@ function curateReleaseEntry(release, batchId, existingRelease, type = 'scene') {
|
|||
|
||||
if (type === 'scene') {
|
||||
curatedRelease.shoot_id = release.shootId || null;
|
||||
curatedRelease.productionDate = Number(release.productionDate) ? release.productionDate : null;
|
||||
curatedRelease.production_date = Number(release.productionDate) ? release.productionDate : null;
|
||||
curatedRelease.duration = release.duration;
|
||||
}
|
||||
|
||||
|
@ -260,10 +258,7 @@ async function storeReleases(releases) {
|
|||
async function storeMovies(movies) {
|
||||
const [batchId] = await knex('batches').insert({ comment: null }).returning('id');
|
||||
|
||||
console.log(movies);
|
||||
|
||||
const curatedMovieEntries = movies.map(release => curateReleaseEntry(release, batchId, null, 'movie'));
|
||||
console.log(curatedMovieEntries);
|
||||
const storedMovies = await knex.batchInsert('movies', curatedMovieEntries).returning('*');
|
||||
|
||||
const moviesWithId = attachReleaseIds(movies, storedMovies);
|
||||
|
|
Loading…
Reference in New Issue