mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-20 19:03:20 +03:00
Scaffolding for subscription sharing
This commit is contained in:
@@ -307,21 +307,27 @@ exports.getUserVideos = function(user_uid, type) {
|
|||||||
return user['files'][type];
|
return user['files'][type];
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getUserVideo = function(user_uid, file_uid, type, requireSharing = false) {
|
exports.getUserVideo = function(user_uid, file_uid, type, requireSharing = false, reqBody = null) {
|
||||||
if (!type) {
|
// check if it's a subscription first
|
||||||
file = users_db.get('users').find({uid: user_uid}).get(`files.audio`).find({uid: file_uid}).value();
|
let file = null;
|
||||||
if (!file) {
|
if (reqBody && reqBody.subscriptionName) {
|
||||||
file = users_db.get('users').find({uid: user_uid}).get(`files.video`).find({uid: file_uid}).value();
|
file = users_db.get('users').find({uid: user_uid}).get('subscriptions').find({name: reqBody.subscriptionName}).get('videos').find({id: reqBody.fileNames}).value();
|
||||||
if (file) type = 'video';
|
} else {
|
||||||
} else {
|
if (!type) {
|
||||||
type = 'audio';
|
file = users_db.get('users').find({uid: user_uid}).get(`files.audio`).find({uid: file_uid}).value();
|
||||||
|
if (!file) {
|
||||||
|
file = users_db.get('users').find({uid: user_uid}).get(`files.video`).find({uid: file_uid}).value();
|
||||||
|
if (file) type = 'video';
|
||||||
|
} else {
|
||||||
|
type = 'audio';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!file && type) file = users_db.get('users').find({uid: user_uid}).get(`files.${type}`).find({uid: file_uid}).value();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file && type) file = users_db.get('users').find({uid: user_uid}).get(`files.${type}`).find({uid: file_uid}).value();
|
|
||||||
|
|
||||||
// prevent unauthorized users from accessing the file info
|
// prevent unauthorized users from accessing the file info
|
||||||
if (requireSharing && !file['sharingEnabled']) file = null;
|
if (file && requireSharing && !file['sharingEnabled']) file = null;
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user