mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-21 06:03:21 +03:00
Scaffolding for subscription sharing
This commit is contained in:
@@ -307,7 +307,12 @@ 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) {
|
||||||
|
// check if it's a subscription first
|
||||||
|
let file = null;
|
||||||
|
if (reqBody && reqBody.subscriptionName) {
|
||||||
|
file = users_db.get('users').find({uid: user_uid}).get('subscriptions').find({name: reqBody.subscriptionName}).get('videos').find({id: reqBody.fileNames}).value();
|
||||||
|
} else {
|
||||||
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) {
|
||||||
@@ -319,9 +324,10 @@ exports.getUserVideo = function(user_uid, file_uid, type, requireSharing = false
|
|||||||
}
|
}
|
||||||
|
|
||||||
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