Random changes
This commit is contained in:
1 parent
7160669468
commit
0b1a1d989f
17 files changed
+205
-159
No files matched your search
@@ -1,8 +1,31 @@
|
||||
const { Sequelize } = require("sequelize");
|
||||
const Collection = require("../models/Collection");
|
||||
const Genre = require("../models/Genre");
|
||||
const Media = require("../models/Media");
|
||||
|
||||
|
||||
async function initializeData() {
|
||||
initializeGenres();
|
||||
|
||||
|
||||
// const collections = await Collection.findAll({
|
||||
// where: {
|
||||
// posterPath: { [Sequelize.Op.notLike]: '/%' }
|
||||
// }
|
||||
// });
|
||||
|
||||
// collections.forEach(collection => {
|
||||
// Media.create({
|
||||
// mediaable: 'collection',
|
||||
// mediaableId: collection.id,
|
||||
// type: 'poster',
|
||||
// path: collection.posterPath,
|
||||
// isLocal: true,
|
||||
// isSelected: true
|
||||
// })
|
||||
// });
|
||||
|
||||
// console.log(collections);
|
||||
}
|
||||
|
||||
async function initializeGenres() {
|
||||
|
||||
@@ -17,8 +17,8 @@ const Episode = sequelize.define("episode",
|
||||
}
|
||||
},
|
||||
|
||||
name: { type: DataTypes.STRING(200) },
|
||||
overview: { type: DataTypes.STRING(2000) },
|
||||
name: { type: DataTypes.STRING(500) },
|
||||
overview: { type: DataTypes.STRING(3000) },
|
||||
episode_number: { type: DataTypes.INTEGER },
|
||||
episode_type: { type: DataTypes.STRING(60) },
|
||||
runtime: { type: DataTypes.INTEGER },
|
||||
|
||||
@@ -5,23 +5,16 @@ const Media = sequelize.define("media",
|
||||
{
|
||||
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
||||
|
||||
// entryId: {
|
||||
// type: DataTypes.INTEGER,
|
||||
// references: {
|
||||
// model: 'Entries',
|
||||
// key: 'id'
|
||||
// },
|
||||
// field: 'entry_id'
|
||||
// },
|
||||
|
||||
mediaable: { type: Sequelize.STRING },
|
||||
mediaableId: { type: Sequelize.INTEGER, field: 'mediaable_id' },
|
||||
|
||||
type: { type: DataTypes.STRING(50) },
|
||||
path: { type: DataTypes.STRING(200) },
|
||||
|
||||
isLocal: { type: DataTypes.BOOLEAN, field: 'is_local' },
|
||||
isSelected: { type: DataTypes.BOOLEAN, field: 'is_selected', defaultValue: false },
|
||||
isCustom: { type: DataTypes.BOOLEAN, field: 'is_custom', defaultValue: false },
|
||||
isFavorit: { type: DataTypes.BOOLEAN, field: 'is_favorit', defaultValue: false },
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ const Season = sequelize.define("season",
|
||||
}
|
||||
},
|
||||
|
||||
name: { type: DataTypes.STRING(30) },
|
||||
overview: { type: DataTypes.STRING(1000) },
|
||||
name: { type: DataTypes.STRING(500) },
|
||||
overview: { type: DataTypes.STRING(3000) },
|
||||
season_number: { type: DataTypes.INTEGER },
|
||||
episode_count: { type: DataTypes.INTEGER },
|
||||
air_date: { type: DataTypes.DATE },
|
||||
|
||||
@@ -3,7 +3,7 @@ const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const { getSettings } = require('../services/settingsService');
|
||||
const { generatePreview, doGeneratePreview } = require('../services/mediaService');
|
||||
const { doGeneratePreview } = require('../services/mediaService');
|
||||
const { logToFile } = require('../services/logService');
|
||||
|
||||
const mediaRouter = express.Router();
|
||||
@@ -32,7 +32,7 @@ mediaRouter.get('/:category/:type/:size/:fileName', (req, res, next) => {
|
||||
// ? if so I make sure to change the extention to '_preview.jpg' (bcs all previews are jpg)
|
||||
let filePath = path.join(mediaPath, fileName);
|
||||
if (size == 'preview') {
|
||||
const previewFileName = fileName.split('.')[0] + '_preview.jpg'
|
||||
const previewFileName = fileName.split('.')[0] + (type == 'logos' ? '_preview.png' : '_preview.jpg')
|
||||
filePath = path.join(mediaPath, previewFileName);
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ function doGeneratePreview(fileCategory, fileType, originalFileName, previewWidt
|
||||
const originalPath = path.join(mediaPath, originalFileName);
|
||||
|
||||
const fileNameWithoutExt = originalFileName.split('.')[0];
|
||||
const previewFileName = fileNameWithoutExt + '_preview.jpg'
|
||||
const previewFileName = fileNameWithoutExt + '_preview.jpg';
|
||||
const previewPath = path.join(mediaPath, previewFileName);
|
||||
|
||||
if (previewWidth == 0) {
|
||||
@@ -154,10 +154,16 @@ function doGeneratePreview(fileCategory, fileType, originalFileName, previewWidt
|
||||
if (fileType == 'logos') previewWidth = 300;
|
||||
}
|
||||
|
||||
return sharp(originalPath)
|
||||
.resize({ width: previewWidth })
|
||||
.jpeg({ quality: previewQuality })
|
||||
.toFile(previewPath);
|
||||
if (fileType == 'logos') {
|
||||
return sharp(originalPath)
|
||||
.resize({ width: previewWidth })
|
||||
.toFile(previewPath.replace('.jpg', '.png'));
|
||||
} else {
|
||||
return sharp(originalPath)
|
||||
.resize({ width: previewWidth })
|
||||
.jpeg({ quality: previewQuality })
|
||||
.toFile(previewPath);
|
||||
}
|
||||
}
|
||||
|
||||
function getMediaFolder() {
|
||||
|
||||
@@ -336,14 +336,19 @@ async function refrechEntry(entryId) {
|
||||
{ model: EntrySeen, as: 'entrySeen' },
|
||||
{ model: Season, as: 'seasons' },
|
||||
{ model: Media, as: 'medias' },
|
||||
{
|
||||
model: Collection, as: 'collections',
|
||||
include: [
|
||||
{ model: Media, as: 'medias' }
|
||||
]
|
||||
},
|
||||
{
|
||||
model: Genre,
|
||||
as: 'genres',
|
||||
attributes: ['id'],
|
||||
through: {
|
||||
attributes: []
|
||||
}
|
||||
}
|
||||
],
|
||||
order: [
|
||||
[{ model: EntrySeen, as: 'entrySeen' }, 'date_seen', 'DESC'] // Order the entry-seen list
|
||||
]
|
||||
});
|
||||
|
||||
@@ -437,7 +442,7 @@ async function refrechEntry(entryId) {
|
||||
await existingSeason.save();
|
||||
} else {
|
||||
// Create a new season
|
||||
await Season.create({
|
||||
existingSeason = await Season.create({
|
||||
tmdb_id: seasonData.id,
|
||||
entry_id: oldEntry.id,
|
||||
name: seasonData.name,
|
||||
@@ -547,26 +552,46 @@ async function refrechEntry(entryId) {
|
||||
// + end of: refrech logic
|
||||
|
||||
// ! returning the refreshed entry
|
||||
let includes = [
|
||||
{ model: EntryId, as: 'entryId' },
|
||||
{ model: EntryRating, as: 'entryRating' },
|
||||
{ model: EntrySeen, as: 'entrySeen' },
|
||||
{ model: Season, as: 'seasons' },
|
||||
{ model: Media, as: 'medias' },
|
||||
{ model: Collection, as: 'collections' },
|
||||
{
|
||||
model: Genre,
|
||||
as: 'genres',
|
||||
attributes: ['name'],
|
||||
through: {
|
||||
attributes: []
|
||||
}
|
||||
}
|
||||
];
|
||||
if (oldEntry.is_tvseries) includes.push({ model: Season, as: 'seasons' });
|
||||
// let includes = [
|
||||
// { model: EntryId, as: 'entryId' },
|
||||
// { model: EntryRating, as: 'entryRating' },
|
||||
// { model: EntrySeen, as: 'entrySeen' },
|
||||
// { model: Season, as: 'seasons' },
|
||||
// { model: Media, as: 'medias' },
|
||||
// { model: Collection, as: 'collections' },
|
||||
// {
|
||||
// model: Genre,
|
||||
// as: 'genres',
|
||||
// attributes: ['name'],
|
||||
// through: {
|
||||
// attributes: []
|
||||
// }
|
||||
// }
|
||||
// ];
|
||||
// if (oldEntry.is_tvseries) includes.push({ model: Season, as: 'seasons' });
|
||||
|
||||
const updatedEntry = await Entry.findByPk(entryId, {
|
||||
include: includes,
|
||||
include: [
|
||||
{ model: EntryId, as: 'entryId' },
|
||||
{ model: EntryRating, as: 'entryRating' },
|
||||
{ model: EntrySeen, as: 'entrySeen' },
|
||||
{ model: Season, as: 'seasons' },
|
||||
{ model: Media, as: 'medias' },
|
||||
{
|
||||
model: Collection, as: 'collections',
|
||||
include: [
|
||||
{ model: Media, as: 'medias' }
|
||||
]
|
||||
},
|
||||
{
|
||||
model: Genre,
|
||||
as: 'genres',
|
||||
attributes: ['name'], // Only fetch the genre ID
|
||||
through: {
|
||||
attributes: [] // Do not fetch any attributes from the join table
|
||||
}
|
||||
}
|
||||
],
|
||||
order: [
|
||||
[{ model: EntrySeen, as: 'entrySeen' }, 'date_seen', 'DESC'] // Order the entry-seen list
|
||||
]
|
||||
@@ -575,7 +600,7 @@ async function refrechEntry(entryId) {
|
||||
const plainEntry = updatedEntry.get({ plain: true });
|
||||
plainEntry.genres = plainEntry.genres.map(genre => genre.name);
|
||||
|
||||
return entryData;
|
||||
return plainEntry;
|
||||
}
|
||||
|
||||
/** This function will refresh data of series that have the status not 'ended/canceled' and have not been refreshed today
|
||||
@@ -585,6 +610,7 @@ async function SyncSeriesData() {
|
||||
const entries = await Entry.findAll({
|
||||
where: {
|
||||
is_tvseries: true,
|
||||
autoSync: true,
|
||||
last_fetch: {
|
||||
[Op.ne]: today
|
||||
},
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<!-- filter -->
|
||||
|
||||
<div class="d-flex align-items-baseline gap-3 flex-wrap">
|
||||
<div class="product-count d-flex align-items-center gap-3 gap-lg-4 mb-4 fw-medium flex-wrap font-text1">
|
||||
<div class="product-count d-flex align-items-center gap-3 gap-lg-4 mb-3 fw-medium flex-wrap font-text1">
|
||||
<a href="javascript:;" (click)="onEntryTypeChange(0)"><span class="me-1">All</span><span
|
||||
class="text-secondary">({{entries.length}})</span></a>
|
||||
<a href="javascript:;" (click)="onEntryTypeChange(1)"><span class="me-1">Movies</span><span
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { AfterViewInit, Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { AfterViewInit, Component, OnInit } from '@angular/core';
|
||||
import { Entry } from '../../../shared/models/entry.model';
|
||||
import { LibraryService } from '../../../core/services/library.service';
|
||||
import { ActivatedRoute, Event, NavigationEnd, Router } from '@angular/router';
|
||||
import { ActivatedRoute, Event, Router } from '@angular/router';
|
||||
import { LibraryQueryParams } from '../../../shared/models/library-query-params';
|
||||
import { SettingsService } from '../../../core/services/settings.service';
|
||||
import { Settings } from '../../../shared/models/settings.model';
|
||||
import { ValueSetter } from 'date-fns/parse/_lib/Setter';
|
||||
|
||||
declare var $: any;
|
||||
@Component({
|
||||
@@ -267,6 +266,7 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
|
||||
|
||||
const formattedTitle =
|
||||
this.filterCriteria.title?.toLowerCase().trim() || '';
|
||||
|
||||
temp = await this.entries.filter((entry) => {
|
||||
// * Type check
|
||||
let filterType = this.filterCriteria.type - 1 == 0 ? false : true;
|
||||
@@ -308,6 +308,10 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
|
||||
? entry.title.toLowerCase().includes(formattedTitle) ||
|
||||
entry.original_title.toLowerCase().includes(formattedTitle)
|
||||
: true) ||
|
||||
(entry.network_studio
|
||||
? entry.network_studio.toLowerCase() ==
|
||||
formattedTitle.replace('studio:', '')
|
||||
: true) ||
|
||||
(this.filterCriteria.genres?.length &&
|
||||
this.filterCriteria.genres.some((genre) =>
|
||||
entry.genres.includes(genre)
|
||||
@@ -319,6 +323,7 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
|
||||
);
|
||||
});
|
||||
|
||||
console.log(temp);
|
||||
// ? sort filter
|
||||
temp = await this.sortEntries(temp);
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="logos-content" role="tabpanel">
|
||||
<div class="row row-cols-1 row-cols-md-2 g-4">
|
||||
<div class="row row-cols-1 row-cols-md-5 g-4">
|
||||
<div class="col" *ngFor="let media of filterMedia('logo')">
|
||||
<div class="card image-hover-container">
|
||||
<img [src]="getPath('logos', media)" class="card-img-top" alt="Media Image">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<div class="movie-card" [@fadeInOut]="animationDirection">
|
||||
<div class="movie-card" [@fadeInOut]="animationDirection" appContextMenuTrigger
|
||||
[menuOptions]="contextMenuOptions">
|
||||
<div class="card-head">
|
||||
<img class="card-img" [src]="posterPath" alt="Movie Poster"
|
||||
onerror="this.src='assets/images/default/default-poster.png'">
|
||||
|
||||
@@ -13,6 +13,7 @@ import { LibraryService } from '../../../../core/services/library.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { ConfirmModalComponent } from '../../modals/confirm-modal/confirm-modal.component';
|
||||
import { environment } from '../../../../../environments/environment.prod';
|
||||
import { CONTEXT_MENU_OPTIONS } from '../../../constants/context-menu-options';
|
||||
|
||||
@Component({
|
||||
selector: 'app-main-card',
|
||||
@@ -251,4 +252,22 @@ export class MainCardComponent implements OnInit {
|
||||
if (this.entry.runtime == null) return '';
|
||||
return this.entry.runtime;
|
||||
}
|
||||
|
||||
get contextMenuOptions() {
|
||||
let options = [];
|
||||
|
||||
// ? 1 - is in library
|
||||
if (this.entry.isInLibrary) {
|
||||
if (this.entry.watchlist) {
|
||||
options.push(CONTEXT_MENU_OPTIONS.removeFromWatchlist);
|
||||
} else {
|
||||
options.push(CONTEXT_MENU_OPTIONS.addToWatchlist);
|
||||
}
|
||||
} else {
|
||||
// ? 2 - not in library
|
||||
options.push(CONTEXT_MENU_OPTIONS.addToLibrary);
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Collection } from './collection.model';
|
||||
import { Entry } from './entry.model';
|
||||
|
||||
export interface Media {
|
||||
@@ -7,12 +8,15 @@ export interface Media {
|
||||
mediaable: string;
|
||||
mediaableId: number;
|
||||
entry: Entry;
|
||||
collection: Collection;
|
||||
|
||||
type: string;
|
||||
path: string;
|
||||
|
||||
isLocal: boolean;
|
||||
isSelected: boolean;
|
||||
isCustom: boolean;
|
||||
isFavorit: boolean;
|
||||
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Entry } from './entry.model';
|
||||
import { Episode } from './episode.models';
|
||||
|
||||
export interface Season {
|
||||
@@ -9,6 +10,7 @@ export interface Season {
|
||||
imdb_id: string;
|
||||
|
||||
entry_id: number;
|
||||
entry: Entry;
|
||||
|
||||
name: string;
|
||||
overview: string;
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
import {
|
||||
Injectable,
|
||||
ComponentFactoryResolver,
|
||||
ApplicationRef,
|
||||
Injector,
|
||||
EmbeddedViewRef,
|
||||
ComponentRef,
|
||||
} from '@angular/core';
|
||||
import { NotificationPopupComponent } from '../components/notification-popup/notification-popup.component';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class NotificationService {
|
||||
private notificationComponents: ComponentRef<NotificationPopupComponent>[] =
|
||||
[];
|
||||
private notificationBottomMargin = 10; // Margin between notifications
|
||||
private baseBottomPosition = 20; // Starting bottom position for the first notification
|
||||
|
||||
constructor(
|
||||
private componentFactoryResolver: ComponentFactoryResolver,
|
||||
private appRef: ApplicationRef,
|
||||
private injector: Injector
|
||||
) {}
|
||||
|
||||
public showNotification(
|
||||
title: string,
|
||||
message: string,
|
||||
type: string = 'alert',
|
||||
timeout: number = 5000
|
||||
): void {
|
||||
// Create a component reference for the notification
|
||||
const componentRef = this.componentFactoryResolver
|
||||
.resolveComponentFactory(NotificationPopupComponent)
|
||||
.create(this.injector);
|
||||
|
||||
// Assign the message and type to the instance
|
||||
componentRef.instance.title = title;
|
||||
componentRef.instance.message = message;
|
||||
componentRef.instance.type = type;
|
||||
|
||||
// Attach the component to the application
|
||||
this.appRef.attachView(componentRef.hostView);
|
||||
|
||||
// Convert the component's host view into a DOM element and append it to the body
|
||||
const domElem = (componentRef.hostView as EmbeddedViewRef<any>)
|
||||
.rootNodes[0] as HTMLElement;
|
||||
document.body.appendChild(domElem);
|
||||
|
||||
const position =
|
||||
this.baseBottomPosition +
|
||||
this.notificationComponents.length *
|
||||
(domElem.offsetHeight + this.notificationBottomMargin);
|
||||
domElem.style.bottom = `${position}px`;
|
||||
domElem.style.position = 'fixed';
|
||||
domElem.style.right = '20px';
|
||||
|
||||
// Store the component reference for later removal
|
||||
this.notificationComponents.push(componentRef);
|
||||
|
||||
// Remove the notification after a delay
|
||||
setTimeout(() => {
|
||||
domElem.style.visibility = 'hidden';
|
||||
}, timeout);
|
||||
|
||||
setTimeout(() => {
|
||||
this.removeNotification(componentRef);
|
||||
}, timeout + 1000); // Customize this value as needed
|
||||
}
|
||||
|
||||
// private removeNotification(
|
||||
// componentRef: ComponentRef<NotificationPopupComponent>
|
||||
// ): void {
|
||||
// this.appRef.detachView(componentRef.hostView);
|
||||
// componentRef.destroy();
|
||||
// this.notificationComponents = this.notificationComponents.filter(
|
||||
// (c) => c !== componentRef
|
||||
// );
|
||||
// }
|
||||
|
||||
private removeNotification(
|
||||
componentRef: ComponentRef<NotificationPopupComponent>
|
||||
): void {
|
||||
const domElem = (componentRef.hostView as EmbeddedViewRef<any>)
|
||||
.rootNodes[0] as HTMLElement;
|
||||
this.appRef.detachView(componentRef.hostView);
|
||||
document.body.removeChild(domElem); // Make sure to remove the element from the body
|
||||
componentRef.destroy();
|
||||
// Filter out the destroyed notification
|
||||
this.notificationComponents = this.notificationComponents.filter(
|
||||
(c) => c !== componentRef
|
||||
);
|
||||
|
||||
// Adjust positions of remaining notifications
|
||||
this.adjustPositions();
|
||||
}
|
||||
|
||||
private adjustPositions(): void {
|
||||
// Start from the initial position again and reposition each remaining notification
|
||||
this.notificationComponents.forEach((componentRef, index) => {
|
||||
const domElem = (componentRef.hostView as EmbeddedViewRef<any>)
|
||||
.rootNodes[0] as HTMLElement;
|
||||
const position =
|
||||
this.baseBottomPosition +
|
||||
index * (domElem.offsetHeight + this.notificationBottomMargin);
|
||||
domElem.style.bottom = `${position}px`;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ProgressAnimationType, ToastrService } from 'ngx-toastr';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ToastService {
|
||||
constructor(private toastr: ToastrService) {}
|
||||
|
||||
public show(title: string, message: string, type: string = 'success'): void {
|
||||
const options = {
|
||||
tapToDismiss: true,
|
||||
progressBar: true,
|
||||
positionClass: 'top-right',
|
||||
progressAnimation: 'increasing' as ProgressAnimationType,
|
||||
};
|
||||
|
||||
if (type == 'success') this.toastr.show(title, message, options);
|
||||
else if (type == 'error') this.toastr.error(title, message, options);
|
||||
else if (type == 'warning') this.toastr.warning(title, message, options);
|
||||
else if (type == 'info') this.toastr.info(title, message, options);
|
||||
}
|
||||
|
||||
public showWithOptions(
|
||||
title: string,
|
||||
message: string,
|
||||
type: string = 'success',
|
||||
extraOptions: any
|
||||
): void {
|
||||
const options = {
|
||||
tapToDismiss: true,
|
||||
progressBar: true,
|
||||
positionClass: 'top-right',
|
||||
progressAnimation: 'increasing' as ProgressAnimationType,
|
||||
...extraOptions,
|
||||
};
|
||||
|
||||
if (type == 'success') this.toastr.success(title, message, options);
|
||||
else if (type == 'error') this.toastr.error(title, message, options);
|
||||
else if (type == 'warning') this.toastr.warning(title, message, options);
|
||||
else if (type == 'info') this.toastr.info(title, message, options);
|
||||
}
|
||||
}
|
||||
@@ -39,4 +39,37 @@
|
||||
--shz-green-success: #02c27a;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* table border lines */
|
||||
[data-bs-theme=dark] body .fc-scrollgrid,
|
||||
[data-bs-theme=dark] body .fc-day {
|
||||
border-color: #878d96;
|
||||
}
|
||||
|
||||
|
||||
/* buttons */
|
||||
[data-bs-theme=dark] body .fc-button,
|
||||
[data-bs-theme=dark] body .fc-today-button {
|
||||
background-color: #2c3034;
|
||||
border-color: #2c3034;
|
||||
}
|
||||
|
||||
[data-bs-theme=dark] body .fc-prev-button:hover,
|
||||
[data-bs-theme=dark] body .fc-next-button:hover,
|
||||
[data-bs-theme=dark] body .fc-today-button:enabled {
|
||||
background-color: #383c40;
|
||||
border-color: #383c40;
|
||||
}
|
||||
|
||||
|
||||
[data-bs-theme=dark] body .fc-today-button:disabled {
|
||||
background-color: #343a40;
|
||||
border-color: #343a40;
|
||||
}
|
||||
|
||||
|
||||
/* calendar header */
|
||||
[data-bs-theme=dark] body .fc-col-header {
|
||||
background-color: #212529;
|
||||
}
|
||||
Reference in new issue
Block a user