mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-22 12:40:56 +03:00
Compare commits
1 Commits
fix-playli
...
kodi-integ
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a623012901 |
@@ -90,7 +90,7 @@ environment:
|
|||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
[API Docs](https://youtubedl-material.stoplight.io/docs/youtubedl-material/Public%20API%20v1.yaml)
|
[API Docs](https://stoplight.io/p/docs/gh/tzahi12345/youtubedl-material?group=master&utm_campaign=publish_dialog&utm_source=studio)
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
|
|||||||
@@ -1159,12 +1159,7 @@ async function downloadFileByURL_exec(url, type, options, sessionID = null) {
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// store info in download for future use
|
// store info in download for future use
|
||||||
if (Array.isArray(info)) {
|
download['_filename'] = info['_filename'];
|
||||||
download['fileNames'] = [];
|
|
||||||
for (let info_obj of info) download['fileNames'].push(info_obj['_filename']);
|
|
||||||
} else {
|
|
||||||
download['_filename'] = info['_filename'];
|
|
||||||
}
|
|
||||||
download['filesize'] = utils.getExpectedFileSize(info);
|
download['filesize'] = utils.getExpectedFileSize(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1618,15 +1613,12 @@ function checkDownloadPercent(download) {
|
|||||||
Any file that starts with <video title> will be counted as part of the "bytes downloaded", which will
|
Any file that starts with <video title> will be counted as part of the "bytes downloaded", which will
|
||||||
be divided by the "total expected bytes."
|
be divided by the "total expected bytes."
|
||||||
*/
|
*/
|
||||||
// assume it's a playlist for logic reasons
|
const file_id = download['file_id'];
|
||||||
const fileNames = Array.isArray(download['fileNames']) ? download['fileNames']
|
const filename = path.format(path.parse(download['_filename'].substring(0, download['_filename'].length-4)));
|
||||||
: [path.format(path.parse(download['_filename'].substring(0, download['_filename'].length-4)))];
|
|
||||||
|
|
||||||
|
|
||||||
const resulting_file_size = download['filesize'];
|
const resulting_file_size = download['filesize'];
|
||||||
let sum_size = 0;
|
|
||||||
let glob_str = '';
|
glob(`${filename}*`, (err, files) => {
|
||||||
glob(`{${fileNames.join(',')}, }*`, (err, files) => {
|
let sum_size = 0;
|
||||||
files.forEach(file => {
|
files.forEach(file => {
|
||||||
try {
|
try {
|
||||||
const file_stats = fs.statSync(file);
|
const file_stats = fs.statSync(file);
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ function registerFileDB(file_path, type, multiUserMode = null, sub = null) {
|
|||||||
|
|
||||||
utils.fixVideoMetadataPerms(file_id, type, multiUserMode && multiUserMode.file_path);
|
utils.fixVideoMetadataPerms(file_id, type, multiUserMode && multiUserMode.file_path);
|
||||||
|
|
||||||
|
// creates XML if kodi support is enabled
|
||||||
|
if (true) utils.generateNFOFile(file_id, type, multiUserMode && multiUserMode.file_path);
|
||||||
|
|
||||||
// add thumbnail path
|
// add thumbnail path
|
||||||
file_object['thumbnailPath'] = utils.getDownloadedThumbnail(file_id, type, multiUserMode && multiUserMode.file_path);
|
file_object['thumbnailPath'] = utils.getDownloadedThumbnail(file_id, type, multiUserMode && multiUserMode.file_path);
|
||||||
|
|
||||||
|
|||||||
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.1",
|
"version": "2.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz",
|
||||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
|
"integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA=="
|
||||||
},
|
},
|
||||||
"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.1",
|
"node-fetch": "^2.6.0",
|
||||||
"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",
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
var fs = require('fs-extra')
|
var fs = require('fs-extra')
|
||||||
var path = require('path')
|
var path = require('path')
|
||||||
const config_api = require('./config');
|
const config_api = require('./config');
|
||||||
|
const { create } = require('xmlbuilder2');
|
||||||
|
|
||||||
const is_windows = process.platform === 'win32';
|
const is_windows = process.platform === 'win32';
|
||||||
|
|
||||||
@@ -105,27 +106,19 @@ function getDownloadedThumbnail(name, type, customPath = null) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getExpectedFileSize(input_info_jsons) {
|
function getExpectedFileSize(info_json) {
|
||||||
// treat single videos as arrays to have the file sizes checked/added to. makes the code cleaner
|
if (info_json['filesize']) {
|
||||||
const info_jsons = Array.isArray(input_info_jsons) ? input_info_jsons : [input_info_jsons];
|
return info_json['filesize'];
|
||||||
|
}
|
||||||
|
|
||||||
|
const formats = info_json['format_id'].split('+');
|
||||||
let expected_filesize = 0;
|
let expected_filesize = 0;
|
||||||
|
formats.forEach(format_id => {
|
||||||
info_jsons.forEach(info_json => {
|
info_json.formats.forEach(available_format => {
|
||||||
if (info_json['filesize']) {
|
if (available_format.format_id === format_id && available_format.filesize) {
|
||||||
expected_filesize += info_json['filesize'];
|
expected_filesize += available_format.filesize;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
const formats = info_json['format_id'].split('+');
|
|
||||||
let individual_expected_filesize = 0;
|
|
||||||
formats.forEach(format_id => {
|
|
||||||
info_json.formats.forEach(available_format => {
|
|
||||||
if (available_format.format_id === format_id && available_format.filesize) {
|
|
||||||
individual_expected_filesize += available_format.filesize;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
expected_filesize += individual_expected_filesize;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return expected_filesize;
|
return expected_filesize;
|
||||||
@@ -153,6 +146,35 @@ function fixVideoMetadataPerms(name, type, customPath = null) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generateNFOFile(file_id, type, customPath = null) {
|
||||||
|
if (!customPath) customPath = type === 'audio' ? config_api.getConfigItem('ytdl_audio_folder_path')
|
||||||
|
: config_api.getConfigItem('ytdl_video_folder_path');
|
||||||
|
|
||||||
|
const file_obj = getJSONByType(type, file_id, customPath);
|
||||||
|
|
||||||
|
const target_dir = path.dirname(file_obj['_filename']);
|
||||||
|
|
||||||
|
const file_name = path.basename(file_obj['_filename']);
|
||||||
|
const target_file_name = file_name.substring(0, file_name.length-4) + '.nfo';
|
||||||
|
|
||||||
|
const xml_obj = {
|
||||||
|
episodedetails: {
|
||||||
|
title: file_obj['fulltitle'],
|
||||||
|
episode: file_obj['playlist_index'] ? file_obj['playlist_index'] : undefined,
|
||||||
|
premiered: file_obj['upload_date'],
|
||||||
|
plot: `${file_obj['uploader_url']}\n${file_obj['description']}\n${file_obj['playlist_title']}`
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const generated_xml = create(xml_obj).end({prettyPrint: true});
|
||||||
|
|
||||||
|
const xml_parts = generated_xml.split('\n');
|
||||||
|
xml_parts[0] = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
|
||||||
|
const final_xml = xml_parts.join('\n');
|
||||||
|
|
||||||
|
fs.writeFileSync(path.join(target_dir, target_file_name), final_xml);
|
||||||
|
}
|
||||||
|
|
||||||
function deleteJSONFile(name, type, customPath = null) {
|
function deleteJSONFile(name, type, customPath = null) {
|
||||||
if (!customPath) customPath = type === 'audio' ? config_api.getConfigItem('ytdl_audio_folder_path')
|
if (!customPath) customPath = type === 'audio' ? config_api.getConfigItem('ytdl_audio_folder_path')
|
||||||
: config_api.getConfigItem('ytdl_video_folder_path');
|
: config_api.getConfigItem('ytdl_video_folder_path');
|
||||||
@@ -212,6 +234,7 @@ module.exports = {
|
|||||||
getDownloadedThumbnail: getDownloadedThumbnail,
|
getDownloadedThumbnail: getDownloadedThumbnail,
|
||||||
getExpectedFileSize: getExpectedFileSize,
|
getExpectedFileSize: getExpectedFileSize,
|
||||||
fixVideoMetadataPerms: fixVideoMetadataPerms,
|
fixVideoMetadataPerms: fixVideoMetadataPerms,
|
||||||
|
generateNFOFile: generateNFOFile,
|
||||||
deleteJSONFile: deleteJSONFile,
|
deleteJSONFile: deleteJSONFile,
|
||||||
getDownloadedFilesByType: getDownloadedFilesByType,
|
getDownloadedFilesByType: getDownloadedFilesByType,
|
||||||
recFindByExt: recFindByExt,
|
recFindByExt: recFindByExt,
|
||||||
|
|||||||
@@ -50,8 +50,7 @@ export class CustomPlaylistsComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
goToPlaylist(info_obj) {
|
goToPlaylist(playlist) {
|
||||||
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 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' : '' ]">
|
<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' : '' ]">
|
||||||
<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 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' : '' ]">
|
<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' : '' ]">
|
||||||
<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,36 +138,28 @@ export class RecentVideosComponent implements OnInit {
|
|||||||
|
|
||||||
// navigation
|
// navigation
|
||||||
|
|
||||||
goToFile(info_obj) {
|
goToFile(file) {
|
||||||
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, event.ctrlKey);
|
this.navigateToFile(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateToFile(file, new_tab) {
|
navigateToFile(file) {
|
||||||
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) {
|
||||||
// streaming only mode subscriptions
|
this.router.navigate(['/player', {name: file.id,
|
||||||
!new_tab ? this.router.navigate(['/player', {name: file.id,
|
url: file.requested_formats ? file.requested_formats[0].url : file.url}]);
|
||||||
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 {
|
||||||
// normal subscriptions
|
this.router.navigate(['/player', {fileNames: file.id,
|
||||||
!new_tab ? this.router.navigate(['/player', {fileNames: file.id,
|
type: file.isAudio ? 'audio' : 'video', subscriptionName: sub.name,
|
||||||
type: file.isAudio ? 'audio' : 'video', subscriptionName: sub.name,
|
subPlaylist: sub.isPlaylist}]);
|
||||||
subPlaylist: sub.isPlaylist}])
|
|
||||||
: window.open(`/#/player;fileNames=${file.id};type=${file.isAudio ? 'audio' : 'video'};subscriptionName=${sub.name};subPlaylist=${sub.isPlaylist}`);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// normal files
|
this.router.navigate(['/player', {type: file.isAudio ? 'audio' : 'video', uid: file.uid}]);
|
||||||
!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($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}">
|
<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}">
|
||||||
<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(event) {
|
navigateToFile() {
|
||||||
this.goToFile.emit({file: this.file_obj, event: event});
|
this.goToFile.emit(this.file_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateToSubscription() {
|
navigateToSubscription() {
|
||||||
|
|||||||
@@ -181,12 +181,10 @@
|
|||||||
|
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
<ng-container *ngIf="cachedFileManagerEnabled || fileManagerEnabled">
|
<app-recent-videos></app-recent-videos>
|
||||||
<app-recent-videos></app-recent-videos>
|
<br/>
|
||||||
<br/>
|
<h4 style="text-align: center">Custom playlists</h4>
|
||||||
<h4 style="text-align: center">Custom playlists</h4>
|
<app-custom-playlists></app-custom-playlists>
|
||||||
<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,9 +82,8 @@ export class MainComponent implements OnInit {
|
|||||||
useDefaultDownloadingAgent = true;
|
useDefaultDownloadingAgent = true;
|
||||||
customDownloadingAgent = null;
|
customDownloadingAgent = null;
|
||||||
|
|
||||||
// cache
|
// formats cache
|
||||||
cachedAvailableFormats = {};
|
cachedAvailableFormats = {};
|
||||||
cachedFileManagerEnabled = localStorage.getItem('cached_filemanager_enabled') === 'true';
|
|
||||||
|
|
||||||
// youtube api
|
// youtube api
|
||||||
youtubeSearchEnabled = false;
|
youtubeSearchEnabled = false;
|
||||||
@@ -233,8 +232,7 @@ 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'];
|
||||||
@@ -263,10 +261,6 @@ 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';
|
||||||
|
|||||||
Reference in New Issue
Block a user