playlist download progress, fix library error downloading
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
"test:e2e": "jest --config ./test/jest-e2e.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@distube/ytdl-core": "^4.13.5",
|
||||
"@nestjs/common": "^10.0.0",
|
||||
"@nestjs/config": "^3.2.2",
|
||||
"@nestjs/core": "^10.0.0",
|
||||
@@ -35,8 +36,7 @@
|
||||
"rxjs": "^7.8.1",
|
||||
"spotify-url-info": "^3.2.15",
|
||||
"sqlite3": "^5.1.7",
|
||||
"yt-search": "^2.11.0",
|
||||
"ytdl-core": "^4.11.5"
|
||||
"yt-search": "^2.11.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "^10.0.0",
|
||||
|
||||
@@ -7,12 +7,15 @@ export class PlaylistEntity {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column()
|
||||
name: string;
|
||||
@Column({ nullable: true })
|
||||
name?: string;
|
||||
|
||||
@Column()
|
||||
spotifyUrl: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
error?: string;
|
||||
|
||||
@Column({default: () => Date.now()})
|
||||
createdAt?: number;
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
export interface PlaylistModel {
|
||||
id: number;
|
||||
name: string;
|
||||
name?: string;
|
||||
spotifyUrl: string;
|
||||
tracks?: any[]; //todo fix it
|
||||
error?: string;
|
||||
createdAt?: number;
|
||||
}
|
||||
@@ -33,10 +33,17 @@ export class PlaylistService {
|
||||
}
|
||||
|
||||
async create(playlist: PlaylistEntity): Promise<void> {
|
||||
const details = await getDetails(playlist.spotifyUrl);
|
||||
const savedPlaylist = await this.repository.save({...playlist, name: details.preview.title});
|
||||
let details;
|
||||
let playlist2Save: PlaylistEntity;
|
||||
try {
|
||||
details = await getDetails(playlist.spotifyUrl);
|
||||
playlist2Save = {...playlist, name: details.preview.title};
|
||||
} catch (err) {
|
||||
playlist2Save = {...playlist, error: String(err)};
|
||||
}
|
||||
const savedPlaylist = await this.repository.save(playlist2Save);
|
||||
this.io.emit('playlistNew', savedPlaylist);
|
||||
for(let track of details.tracks) {
|
||||
for(let track of details?.tracks ?? []) {
|
||||
await this.trackService.create({
|
||||
artist: track.artist,
|
||||
song: track.name,
|
||||
|
||||
@@ -6,7 +6,7 @@ import {PlaylistEntity} from "../playlist/playlist.entity";
|
||||
import {Interval} from "@nestjs/schedule";
|
||||
import {TrackStatusEnum} from "./track.model";
|
||||
import * as yts from 'yt-search';
|
||||
import * as ytdl from 'ytdl-core';
|
||||
import * as ytdl from '@distube/ytdl-core';
|
||||
import * as fs from 'fs';
|
||||
import {ConfigService} from "@nestjs/config";
|
||||
import {resolve} from "path";
|
||||
|
||||
Reference in New Issue
Block a user