mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-10 00:31:30 +03:00
Added ability to randomize playlists
Missing videos now show a more verbose error in the logs
This commit is contained in:
@@ -2399,14 +2399,17 @@ app.get('/api/stream', optionalJwt, async (req, res) => {
|
|||||||
let uid = decodeURIComponent(req.query.uid);
|
let uid = decodeURIComponent(req.query.uid);
|
||||||
|
|
||||||
let file_path = null;
|
let file_path = null;
|
||||||
|
let file_obj = null;
|
||||||
|
|
||||||
const multiUserMode = config_api.getConfigItem('ytdl_multi_user_mode');
|
const multiUserMode = config_api.getConfigItem('ytdl_multi_user_mode');
|
||||||
if (!multiUserMode || req.isAuthenticated() || req.can_watch) {
|
if (!multiUserMode || req.isAuthenticated() || req.can_watch) {
|
||||||
const file_obj = await db_api.getVideo(uid, uuid, sub_id);
|
file_obj = await db_api.getVideo(uid, uuid, sub_id);
|
||||||
if (file_obj) file_path = file_obj['path'];
|
if (file_obj) file_path = file_obj['path'];
|
||||||
else file_path = null;
|
else file_path = null;
|
||||||
}
|
}
|
||||||
|
if (!fs.existsSync(file_path)) {
|
||||||
|
logger.error(`File ${file_path} could not be found! UID: ${uid}, ID: ${file_obj.id}`);
|
||||||
|
}
|
||||||
const stat = fs.statSync(file_path)
|
const stat = fs.statSync(file_path)
|
||||||
const fileSize = stat.size
|
const fileSize = stat.size
|
||||||
const range = req.headers.range
|
const range = req.headers.range
|
||||||
|
|||||||
@@ -413,6 +413,7 @@ exports.createPlaylist = async (playlist_name, uids, type, thumbnail_url, user_u
|
|||||||
thumbnailURL: thumbnail_url,
|
thumbnailURL: thumbnail_url,
|
||||||
type: type,
|
type: type,
|
||||||
registered: Date.now(),
|
registered: Date.now(),
|
||||||
|
randomize_order: false
|
||||||
};
|
};
|
||||||
|
|
||||||
const duration = await exports.calculatePlaylistDuration(new_playlist, user_uid);
|
const duration = await exports.calculatePlaylistDuration(new_playlist, user_uid);
|
||||||
|
|||||||
@@ -9,6 +9,10 @@
|
|||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<mat-checkbox [(ngModel)]="playlist.randomize_order"><ng-container i18n="Randomize order when playing checkbox label">Randomize order when playing</ng-container></mat-checkbox>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div style="margin-bottom: 10px; height: 40px;">
|
<div style="margin-bottom: 10px; height: 40px;">
|
||||||
<div style="float: left">
|
<div style="float: left">
|
||||||
<span *ngIf="reverse_order === false" i18n="Normal order">Normal order </span>
|
<span *ngIf="reverse_order === false" i18n="Normal order">Normal order </span>
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ export class ModifyPlaylistComponent implements OnInit {
|
|||||||
index = this.playlist_file_objs.length - 1 - index;
|
index = this.playlist_file_objs.length - 1 - index;
|
||||||
}
|
}
|
||||||
this.playlist_file_objs.splice(index, 1);
|
this.playlist_file_objs.splice(index, 1);
|
||||||
|
this.playlist.uids.splice(index, 1);
|
||||||
this.processFiles();
|
this.processFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,13 +55,13 @@
|
|||||||
</ng-container>
|
</ng-container>
|
||||||
</mat-drawer>
|
</mat-drawer>
|
||||||
|
|
||||||
<div class="update-playlist-button-div" *ngIf="id && playlistChanged()">
|
<!-- <div class="update-playlist-button-div" *ngIf="id && playlistChanged()">
|
||||||
<div class="spinner-div">
|
<div class="spinner-div">
|
||||||
<mat-spinner *ngIf="playlist_updating" [diameter]="25"></mat-spinner>
|
<mat-spinner *ngIf="playlist_updating" [diameter]="25"></mat-spinner>
|
||||||
</div>
|
</div>
|
||||||
<button color="primary" [disabled]="playlist_updating" (click)="updatePlaylist()" mat-raised-button><ng-container i18n="Playlist save changes button">Save changes</ng-container> <mat-icon>update</mat-icon></button>
|
<button color="primary" [disabled]="playlist_updating" (click)="updatePlaylist()" mat-raised-button><ng-container i18n="Playlist save changes button">Save changes</ng-container> <mat-icon>update</mat-icon></button>
|
||||||
|
|
||||||
</div>
|
</div> -->
|
||||||
</mat-drawer-container>
|
</mat-drawer-container>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -233,6 +233,9 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
this.playlist.push(mediaObject);
|
this.playlist.push(mediaObject);
|
||||||
}
|
}
|
||||||
|
if (this.db_playlist && this.db_playlist['randomize_order']) {
|
||||||
|
this.shuffleArray(this.playlist);
|
||||||
|
}
|
||||||
this.currentItem = this.playlist[this.currentIndex];
|
this.currentItem = this.playlist[this.currentIndex];
|
||||||
this.original_playlist = JSON.stringify(this.playlist);
|
this.original_playlist = JSON.stringify(this.playlist);
|
||||||
this.show_player = true;
|
this.show_player = true;
|
||||||
@@ -409,6 +412,13 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
this.api.playbackRate = speed;
|
this.api.playbackRate = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shuffleArray(array) {
|
||||||
|
for (let i = array.length - 1; i > 0; i--) {
|
||||||
|
const j = Math.floor(Math.random() * (i + 1));
|
||||||
|
[array[i], array[j]] = [array[j], array[i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// snackbar helper
|
// snackbar helper
|
||||||
public openSnackBar(message: string, action: string) {
|
public openSnackBar(message: string, action: string) {
|
||||||
this.snackBar.open(message, action, {
|
this.snackBar.open(message, action, {
|
||||||
|
|||||||
Reference in New Issue
Block a user