mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-07 05:41:30 +03:00
Compare commits
10 Commits
kodi-integ
...
fix-playli
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6717a59422 | ||
|
|
899633e124 | ||
|
|
8fdc231f08 | ||
|
|
ae8f7a2a33 | ||
|
|
d0782bb444 | ||
|
|
49210abb49 | ||
|
|
851bfb81ba | ||
|
|
35d0d439fa | ||
|
|
ded3ad6dfc | ||
|
|
61daf26641 |
@@ -90,7 +90,7 @@ environment:
|
|||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
[API Docs](https://stoplight.io/p/docs/gh/tzahi12345/youtubedl-material?group=master&utm_campaign=publish_dialog&utm_source=studio)
|
[API Docs](https://youtubedl-material.stoplight.io/docs/youtubedl-material/Public%20API%20v1.yaml)
|
||||||
|
|
||||||
To get started, go to the settings menu and enable the public API from the *Extra* tab. You can generate an API key if one is missing.
|
To get started, go to the settings menu and enable the public API from the *Extra* tab. You can generate an API key if one is missing.
|
||||||
|
|
||||||
|
|||||||
@@ -849,12 +849,13 @@ function getVideoFormatID(name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createPlaylistZipFile(fileNames, type, outputName, fullPathProvided = null) {
|
async function createPlaylistZipFile(fileNames, type, outputName, fullPathProvided = null, user_uid = null) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
let zipFolderPath = null;
|
let zipFolderPath = null;
|
||||||
|
|
||||||
if (!fullPathProvided) {
|
if (!fullPathProvided) {
|
||||||
zipFolderPath = path.join(__dirname, (type === 'audio') ? audioFolderPath : videoFolderPath);
|
zipFolderPath = path.join(type === 'audio' ? audioFolderPath : videoFolderPath);
|
||||||
|
if (user_uid) zipFolderPath = path.join(config_api.getConfigItem('ytdl_users_base_path'), user_uid, zipFolderPath);
|
||||||
} else {
|
} else {
|
||||||
zipFolderPath = path.join(__dirname, config_api.getConfigItem('ytdl_subscriptions_base_path'));
|
zipFolderPath = path.join(__dirname, config_api.getConfigItem('ytdl_subscriptions_base_path'));
|
||||||
}
|
}
|
||||||
@@ -879,7 +880,7 @@ async function createPlaylistZipFile(fileNames, type, outputName, fullPathProvid
|
|||||||
for (let i = 0; i < fileNames.length; i++) {
|
for (let i = 0; i < fileNames.length; i++) {
|
||||||
let fileName = fileNames[i];
|
let fileName = fileNames[i];
|
||||||
let fileNamePathRemoved = path.parse(fileName).base;
|
let fileNamePathRemoved = path.parse(fileName).base;
|
||||||
let file_path = !fullPathProvided ? zipFolderPath + fileName + ext : fileName;
|
let file_path = !fullPathProvided ? path.join(zipFolderPath, fileName + ext) : fileName;
|
||||||
archive.file(file_path, {name: fileNamePathRemoved + ext})
|
archive.file(file_path, {name: fileNamePathRemoved + ext})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1793,9 +1794,9 @@ const optionalJwt = function (req, res, next) {
|
|||||||
const uuid = using_body ? req.body.uuid : req.query.uuid;
|
const uuid = using_body ? req.body.uuid : req.query.uuid;
|
||||||
const uid = using_body ? req.body.uid : req.query.uid;
|
const uid = using_body ? req.body.uid : req.query.uid;
|
||||||
const type = using_body ? req.body.type : req.query.type;
|
const type = using_body ? req.body.type : req.query.type;
|
||||||
const file = !req.query.id ? auth_api.getUserVideo(uuid, uid, type, true, req.body) : auth_api.getUserPlaylist(uuid, req.query.id, null, true);
|
const playlist_id = using_body ? req.body.id : req.query.id;
|
||||||
const is_shared = file ? file['sharingEnabled'] : false;
|
const file = !playlist_id ? auth_api.getUserVideo(uuid, uid, type, true, req.body) : auth_api.getUserPlaylist(uuid, playlist_id, null, false);
|
||||||
if (is_shared) {
|
if (file) {
|
||||||
req.can_watch = true;
|
req.can_watch = true;
|
||||||
return next();
|
return next();
|
||||||
} else {
|
} else {
|
||||||
@@ -2000,7 +2001,7 @@ app.post('/api/getAllFiles', optionalJwt, function (req, res) {
|
|||||||
let audios = null;
|
let audios = null;
|
||||||
let audio_playlists = null;
|
let audio_playlists = null;
|
||||||
let video_playlists = null;
|
let video_playlists = null;
|
||||||
let subscriptions = subscriptions_api.getAllSubscriptions(req.isAuthenticated() ? req.user.uid : null);
|
let subscriptions = config_api.getConfigItem('ytdl_allow_subscriptions') ? (subscriptions_api.getAllSubscriptions(req.isAuthenticated() ? req.user.uid : null)) : [];
|
||||||
|
|
||||||
// get basic info depending on multi-user mode being enabled
|
// get basic info depending on multi-user mode being enabled
|
||||||
if (req.isAuthenticated()) {
|
if (req.isAuthenticated()) {
|
||||||
@@ -2548,7 +2549,8 @@ app.post('/api/downloadFile', optionalJwt, async (req, res) => {
|
|||||||
for (let i = 0; i < fileNames.length; i++) {
|
for (let i = 0; i < fileNames.length; i++) {
|
||||||
fileNames[i] = decodeURIComponent(fileNames[i]);
|
fileNames[i] = decodeURIComponent(fileNames[i]);
|
||||||
}
|
}
|
||||||
file = await createPlaylistZipFile(fileNames, type, outputName, fullPathProvided);
|
file = await createPlaylistZipFile(fileNames, type, outputName, fullPathProvided, req.body.uuid);
|
||||||
|
file = path.join(__dirname, file);
|
||||||
}
|
}
|
||||||
res.sendFile(file, function (err) {
|
res.sendFile(file, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
@@ -283,6 +283,7 @@ exports.getUserVideos = function(user_uid, type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exports.getUserVideo = function(user_uid, file_uid, type, requireSharing = false) {
|
exports.getUserVideo = function(user_uid, file_uid, type, requireSharing = false) {
|
||||||
|
let file = null;
|
||||||
if (!type) {
|
if (!type) {
|
||||||
file = users_db.get('users').find({uid: user_uid}).get(`files.audio`).find({uid: file_uid}).value();
|
file = users_db.get('users').find({uid: user_uid}).get(`files.audio`).find({uid: file_uid}).value();
|
||||||
if (!file) {
|
if (!file) {
|
||||||
|
|||||||
6
backend/package-lock.json
generated
6
backend/package-lock.json
generated
@@ -1968,9 +1968,9 @@
|
|||||||
"integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
|
"integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
|
||||||
},
|
},
|
||||||
"node-fetch": {
|
"node-fetch": {
|
||||||
"version": "2.6.0",
|
"version": "2.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||||
"integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA=="
|
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
|
||||||
},
|
},
|
||||||
"node-id3": {
|
"node-id3": {
|
||||||
"version": "0.1.16",
|
"version": "0.1.16",
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
"md5": "^2.2.1",
|
"md5": "^2.2.1",
|
||||||
"merge-files": "^0.1.2",
|
"merge-files": "^0.1.2",
|
||||||
"multer": "^1.4.2",
|
"multer": "^1.4.2",
|
||||||
"node-fetch": "^2.6.0",
|
"node-fetch": "^2.6.1",
|
||||||
"node-id3": "^0.1.14",
|
"node-id3": "^0.1.14",
|
||||||
"nodemon": "^2.0.2",
|
"nodemon": "^2.0.2",
|
||||||
"passport": "^0.4.1",
|
"passport": "^0.4.1",
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ export class CustomPlaylistsComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
goToPlaylist(playlist) {
|
goToPlaylist(info_obj) {
|
||||||
|
const playlist = info_obj.file;
|
||||||
const playlistID = playlist.id;
|
const playlistID = playlist.id;
|
||||||
const type = playlist.type;
|
const type = playlist.type;
|
||||||
|
|
||||||
|
|||||||
@@ -31,12 +31,12 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<ng-container *ngIf="normal_files_received">
|
<ng-container *ngIf="normal_files_received">
|
||||||
<div *ngFor="let file of filtered_files; let i = index" class="mb-2 mt-2" [ngClass]="[ postsService.card_size === 'small' ? 'col-2 small-col' : '', postsService.card_size === 'medium' ? 'col-6 col-lg-4 medium-col' : '', postsService.card_size === 'large' ? 'col-12 large-col' : '' ]">
|
<div *ngFor="let file of filtered_files; let i = index" class="mb-2 mt-2 d-flex justify-content-center" [ngClass]="[ postsService.card_size === 'small' ? 'col-2 small-col' : '', postsService.card_size === 'medium' ? 'col-6 col-lg-4 medium-col' : '', postsService.card_size === 'large' ? 'col-12 large-col' : '' ]">
|
||||||
<app-unified-file-card [index]="i" [card_size]="postsService.card_size" (goToFile)="goToFile($event)" (goToSubscription)="goToSubscription($event)" [file_obj]="file" [use_youtubedl_archive]="postsService.config['Downloader']['use_youtubedl_archive']" [loading]="false" (deleteFile)="deleteFile($event)"></app-unified-file-card>
|
<app-unified-file-card [index]="i" [card_size]="postsService.card_size" (goToFile)="goToFile($event)" (goToSubscription)="goToSubscription($event)" [file_obj]="file" [use_youtubedl_archive]="postsService.config['Downloader']['use_youtubedl_archive']" [loading]="false" (deleteFile)="deleteFile($event)"></app-unified-file-card>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container *ngIf="!normal_files_received && loading_files && loading_files.length > 0">
|
<ng-container *ngIf="!normal_files_received && loading_files && loading_files.length > 0">
|
||||||
<div *ngFor="let file of loading_files; let i = index" class="mb-2 mt-2" [ngClass]="[ postsService.card_size === 'small' ? 'col-2 small-col' : '', postsService.card_size === 'medium' ? 'col-6 col-lg-4 medium-col' : '', postsService.card_size === 'large' ? 'col-12 large-col' : '' ]">
|
<div *ngFor="let file of loading_files; let i = index" class="mb-2 mt-2 d-flex justify-content-center" [ngClass]="[ postsService.card_size === 'small' ? 'col-2 small-col' : '', postsService.card_size === 'medium' ? 'col-6 col-lg-4 medium-col' : '', postsService.card_size === 'large' ? 'col-12 large-col' : '' ]">
|
||||||
<app-unified-file-card [index]="i" [card_size]="postsService.card_size" [loading]="true" [theme]="postsService.theme"></app-unified-file-card>
|
<app-unified-file-card [index]="i" [card_size]="postsService.card_size" [loading]="true" [theme]="postsService.theme"></app-unified-file-card>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|||||||
@@ -138,28 +138,36 @@ export class RecentVideosComponent implements OnInit {
|
|||||||
|
|
||||||
// navigation
|
// navigation
|
||||||
|
|
||||||
goToFile(file) {
|
goToFile(info_obj) {
|
||||||
|
const file = info_obj['file'];
|
||||||
|
const event = info_obj['event'];
|
||||||
if (this.postsService.config['Extra']['download_only_mode']) {
|
if (this.postsService.config['Extra']['download_only_mode']) {
|
||||||
this.downloadFile(file);
|
this.downloadFile(file);
|
||||||
} else {
|
} else {
|
||||||
this.navigateToFile(file);
|
this.navigateToFile(file, event.ctrlKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateToFile(file) {
|
navigateToFile(file, new_tab) {
|
||||||
localStorage.setItem('player_navigator', this.router.url);
|
localStorage.setItem('player_navigator', this.router.url);
|
||||||
if (file.sub_id) {
|
if (file.sub_id) {
|
||||||
const sub = this.postsService.getSubscriptionByID(file.sub_id);
|
const sub = this.postsService.getSubscriptionByID(file.sub_id);
|
||||||
if (sub.streamingOnly) {
|
if (sub.streamingOnly) {
|
||||||
this.router.navigate(['/player', {name: file.id,
|
// streaming only mode subscriptions
|
||||||
url: file.requested_formats ? file.requested_formats[0].url : file.url}]);
|
!new_tab ? this.router.navigate(['/player', {name: file.id,
|
||||||
|
url: file.requested_formats ? file.requested_formats[0].url : file.url}])
|
||||||
|
: window.open(`/#/player;name=${file.id};url=${file.requested_formats ? file.requested_formats[0].url : file.url}`);
|
||||||
} else {
|
} else {
|
||||||
this.router.navigate(['/player', {fileNames: file.id,
|
// normal subscriptions
|
||||||
type: file.isAudio ? 'audio' : 'video', subscriptionName: sub.name,
|
!new_tab ? this.router.navigate(['/player', {fileNames: file.id,
|
||||||
subPlaylist: sub.isPlaylist}]);
|
type: file.isAudio ? 'audio' : 'video', subscriptionName: sub.name,
|
||||||
|
subPlaylist: sub.isPlaylist}])
|
||||||
|
: window.open(`/#/player;fileNames=${file.id};type=${file.isAudio ? 'audio' : 'video'};subscriptionName=${sub.name};subPlaylist=${sub.isPlaylist}`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.router.navigate(['/player', {type: file.isAudio ? 'audio' : 'video', uid: file.uid}]);
|
// normal files
|
||||||
|
!new_tab ? this.router.navigate(['/player', {type: file.isAudio ? 'audio' : 'video', uid: file.uid}])
|
||||||
|
: window.open(`/#/player;type=${file.isAudio ? 'audio' : 'video'};uid=${file.uid}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
<button mat-menu-item>Placeholder</button>
|
<button mat-menu-item>Placeholder</button>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</mat-menu>
|
</mat-menu>
|
||||||
<mat-card [matTooltip]="null" (click)="navigateToFile()" matRipple class="file-mat-card" [ngClass]="{'small-mat-card': card_size === 'small', 'file-mat-card': card_size === 'medium', 'large-mat-card': card_size === 'large', 'mat-elevation-z4': !elevated, 'mat-elevation-z8': elevated}">
|
<mat-card [matTooltip]="null" (click)="navigateToFile($event)" matRipple class="file-mat-card" [ngClass]="{'small-mat-card': card_size === 'small', 'file-mat-card': card_size === 'medium', 'large-mat-card': card_size === 'large', 'mat-elevation-z4': !elevated, 'mat-elevation-z8': elevated}">
|
||||||
<div style="padding:5px">
|
<div style="padding:5px">
|
||||||
<div *ngIf="!loading && file_obj.thumbnailURL" class="img-div">
|
<div *ngIf="!loading && file_obj.thumbnailURL" class="img-div">
|
||||||
<div style="position: relative">
|
<div style="position: relative">
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ export class UnifiedFileCardComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateToFile() {
|
navigateToFile(event) {
|
||||||
this.goToFile.emit(this.file_obj);
|
this.goToFile.emit({file: this.file_obj, event: event});
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateToSubscription() {
|
navigateToSubscription() {
|
||||||
|
|||||||
@@ -181,10 +181,12 @@
|
|||||||
|
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
<app-recent-videos></app-recent-videos>
|
<ng-container *ngIf="cachedFileManagerEnabled || fileManagerEnabled">
|
||||||
<br/>
|
<app-recent-videos></app-recent-videos>
|
||||||
<h4 style="text-align: center">Custom playlists</h4>
|
<br/>
|
||||||
<app-custom-playlists></app-custom-playlists>
|
<h4 style="text-align: center">Custom playlists</h4>
|
||||||
|
<app-custom-playlists></app-custom-playlists>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
<!--<div style="margin: 20px" *ngIf="fileManagerEnabled && (!postsService.isLoggedIn || postsService.permissions.includes('filemanager'))">
|
<!--<div style="margin: 20px" *ngIf="fileManagerEnabled && (!postsService.isLoggedIn || postsService.permissions.includes('filemanager'))">
|
||||||
<mat-accordion>
|
<mat-accordion>
|
||||||
|
|||||||
@@ -82,8 +82,9 @@ export class MainComponent implements OnInit {
|
|||||||
useDefaultDownloadingAgent = true;
|
useDefaultDownloadingAgent = true;
|
||||||
customDownloadingAgent = null;
|
customDownloadingAgent = null;
|
||||||
|
|
||||||
// formats cache
|
// cache
|
||||||
cachedAvailableFormats = {};
|
cachedAvailableFormats = {};
|
||||||
|
cachedFileManagerEnabled = localStorage.getItem('cached_filemanager_enabled') === 'true';
|
||||||
|
|
||||||
// youtube api
|
// youtube api
|
||||||
youtubeSearchEnabled = false;
|
youtubeSearchEnabled = false;
|
||||||
@@ -232,7 +233,8 @@ export class MainComponent implements OnInit {
|
|||||||
|
|
||||||
async loadConfig() {
|
async loadConfig() {
|
||||||
// loading config
|
// loading config
|
||||||
this.fileManagerEnabled = this.postsService.config['Extra']['file_manager_enabled'];
|
this.fileManagerEnabled = this.postsService.config['Extra']['file_manager_enabled']
|
||||||
|
&& (!this.postsService.isLoggedIn || this.postsService.permissions.includes('filemanager'));
|
||||||
this.downloadOnlyMode = this.postsService.config['Extra']['download_only_mode'];
|
this.downloadOnlyMode = this.postsService.config['Extra']['download_only_mode'];
|
||||||
this.allowMultiDownloadMode = this.postsService.config['Extra']['allow_multi_download_mode'];
|
this.allowMultiDownloadMode = this.postsService.config['Extra']['allow_multi_download_mode'];
|
||||||
this.audioFolderPath = this.postsService.config['Downloader']['path-audio'];
|
this.audioFolderPath = this.postsService.config['Downloader']['path-audio'];
|
||||||
@@ -261,6 +263,10 @@ export class MainComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set final cache items
|
// set final cache items
|
||||||
|
|
||||||
|
localStorage.setItem('cached_filemanager_enabled', this.fileManagerEnabled.toString());
|
||||||
|
this.cachedFileManagerEnabled = this.fileManagerEnabled;
|
||||||
|
|
||||||
if (this.allowAdvancedDownload) {
|
if (this.allowAdvancedDownload) {
|
||||||
if (localStorage.getItem('customArgsEnabled') !== null) {
|
if (localStorage.getItem('customArgsEnabled') !== null) {
|
||||||
this.customArgsEnabled = localStorage.getItem('customArgsEnabled') === 'true';
|
this.customArgsEnabled = localStorage.getItem('customArgsEnabled') === 'true';
|
||||||
|
|||||||
@@ -317,7 +317,8 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
|
|
||||||
const zipName = fileNames[0].split(' ')[0] + fileNames[1].split(' ')[0];
|
const zipName = fileNames[0].split(' ')[0] + fileNames[1].split(' ')[0];
|
||||||
this.downloading = true;
|
this.downloading = true;
|
||||||
this.postsService.downloadFileFromServer(fileNames, this.type, zipName).subscribe(res => {
|
this.postsService.downloadFileFromServer(fileNames, this.type, zipName, null, null, null, null,
|
||||||
|
!this.uuid ? this.postsService.user.uid : this.uuid, this.id).subscribe(res => {
|
||||||
this.downloading = false;
|
this.downloading = false;
|
||||||
const blob: Blob = res;
|
const blob: Blob = res;
|
||||||
saveAs(blob, zipName + '.zip');
|
saveAs(blob, zipName + '.zip');
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ export class PostsService implements CanActivate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
downloadFileFromServer(fileName, type, outputName = null, fullPathProvided = null, subscriptionName = null, subPlaylist = null,
|
downloadFileFromServer(fileName, type, outputName = null, fullPathProvided = null, subscriptionName = null, subPlaylist = null,
|
||||||
uid = null, uuid = null) {
|
uid = null, uuid = null, id = null) {
|
||||||
return this.http.post(this.path + 'downloadFile', {fileNames: fileName,
|
return this.http.post(this.path + 'downloadFile', {fileNames: fileName,
|
||||||
type: type,
|
type: type,
|
||||||
zip_mode: Array.isArray(fileName),
|
zip_mode: Array.isArray(fileName),
|
||||||
@@ -232,7 +232,8 @@ export class PostsService implements CanActivate {
|
|||||||
subscriptionName: subscriptionName,
|
subscriptionName: subscriptionName,
|
||||||
subPlaylist: subPlaylist,
|
subPlaylist: subPlaylist,
|
||||||
uuid: uuid,
|
uuid: uuid,
|
||||||
uid: uid
|
uid: uid,
|
||||||
|
id: id
|
||||||
},
|
},
|
||||||
{responseType: 'blob', params: this.httpOptions.params});
|
{responseType: 'blob', params: this.httpOptions.params});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user