mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-17 00:01:28 +03:00
Compare commits
1 Commits
fix-playli
...
blacklist-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f143d449b |
@@ -849,13 +849,12 @@ function getVideoFormatID(name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createPlaylistZipFile(fileNames, type, outputName, fullPathProvided = null, user_uid = null) {
|
async function createPlaylistZipFile(fileNames, type, outputName, fullPathProvided = null) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
let zipFolderPath = null;
|
let zipFolderPath = null;
|
||||||
|
|
||||||
if (!fullPathProvided) {
|
if (!fullPathProvided) {
|
||||||
zipFolderPath = path.join(type === 'audio' ? audioFolderPath : videoFolderPath);
|
zipFolderPath = path.join(__dirname, (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'));
|
||||||
}
|
}
|
||||||
@@ -880,7 +879,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 ? path.join(zipFolderPath, fileName + ext) : fileName;
|
let file_path = !fullPathProvided ? zipFolderPath + fileName + ext : fileName;
|
||||||
archive.file(file_path, {name: fileNamePathRemoved + ext})
|
archive.file(file_path, {name: fileNamePathRemoved + ext})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1240,7 +1239,7 @@ async function downloadFileByURL_exec(url, type, options, sessionID = null) {
|
|||||||
if (options.merged_string !== null && options.merged_string !== undefined) {
|
if (options.merged_string !== null && options.merged_string !== undefined) {
|
||||||
let current_merged_archive = fs.readFileSync(path.join(fileFolderPath, `merged_${type}.txt`), 'utf8');
|
let current_merged_archive = fs.readFileSync(path.join(fileFolderPath, `merged_${type}.txt`), 'utf8');
|
||||||
let diff = current_merged_archive.replace(options.merged_string, '');
|
let diff = current_merged_archive.replace(options.merged_string, '');
|
||||||
const archive_path = options.user ? path.join(fileFolderPath, 'archives', `archive_${type}.txt`) : path.join(archivePath, `archive_${type}.txt`);
|
const archive_path = options.user ? path.join(config_api.getConfigItem('ytdl_users_base_path'), options.user, 'archives', `archive_${type}.txt`) : path.join(archivePath, `archive_${type}.txt`);
|
||||||
fs.appendFileSync(archive_path, diff);
|
fs.appendFileSync(archive_path, diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1375,7 +1374,7 @@ async function downloadFileByURL_normal(url, type, options, sessionID = null) {
|
|||||||
if (options.merged_string !== null && options.merged_string !== undefined) {
|
if (options.merged_string !== null && options.merged_string !== undefined) {
|
||||||
let current_merged_archive = fs.readFileSync(path.join(fileFolderPath, `merged_${type}.txt`), 'utf8');
|
let current_merged_archive = fs.readFileSync(path.join(fileFolderPath, `merged_${type}.txt`), 'utf8');
|
||||||
let diff = current_merged_archive.replace(options.merged_string, '');
|
let diff = current_merged_archive.replace(options.merged_string, '');
|
||||||
const archive_path = options.user ? path.join(fileFolderPath, 'archives', `archive_${type}.txt`) : path.join(archivePath, `archive_${type}.txt`);
|
const archive_path = options.user ? path.join(config_api.getConfigItem('ytdl_users_base_path'), options.user, 'archives', `archive_${type}.txt`) : path.join(archivePath, `archive_${type}.txt`);
|
||||||
fs.appendFileSync(archive_path, diff);
|
fs.appendFileSync(archive_path, diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1476,7 +1475,7 @@ async function generateArgs(url, type, options) {
|
|||||||
|
|
||||||
let useYoutubeDLArchive = config_api.getConfigItem('ytdl_use_youtubedl_archive');
|
let useYoutubeDLArchive = config_api.getConfigItem('ytdl_use_youtubedl_archive');
|
||||||
if (useYoutubeDLArchive) {
|
if (useYoutubeDLArchive) {
|
||||||
const archive_folder = options.user ? path.join(fileFolderPath, 'archives') : archivePath;
|
const archive_folder = options.user ? path.join(config_api.getConfigItem('ytdl_users_base_path'), options.user, 'archives') : archivePath;
|
||||||
const archive_path = path.join(archive_folder, `archive_${type}.txt`);
|
const archive_path = path.join(archive_folder, `archive_${type}.txt`);
|
||||||
|
|
||||||
fs.ensureDirSync(archive_folder);
|
fs.ensureDirSync(archive_folder);
|
||||||
@@ -1486,7 +1485,7 @@ async function generateArgs(url, type, options) {
|
|||||||
fs.closeSync(fs.openSync(archive_path, 'w'));
|
fs.closeSync(fs.openSync(archive_path, 'w'));
|
||||||
}
|
}
|
||||||
|
|
||||||
let blacklist_path = options.user ? path.join(fileFolderPath, 'archives', `blacklist_${type}.txt`) : path.join(archivePath, `blacklist_${type}.txt`);
|
let blacklist_path = options.user ? path.join(config_api.getConfigItem('ytdl_users_base_path'), options.user, 'archives', `blacklist_${type}.txt`) : path.join(archivePath, `blacklist_${type}.txt`);
|
||||||
// create blacklist file if it doesn't exist
|
// create blacklist file if it doesn't exist
|
||||||
if (!fs.existsSync(blacklist_path)) {
|
if (!fs.existsSync(blacklist_path)) {
|
||||||
fs.closeSync(fs.openSync(blacklist_path, 'w'));
|
fs.closeSync(fs.openSync(blacklist_path, 'w'));
|
||||||
@@ -1794,9 +1793,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 playlist_id = using_body ? req.body.id : req.query.id;
|
const file = !req.query.id ? auth_api.getUserVideo(uuid, uid, type, true, req.body) : auth_api.getUserPlaylist(uuid, req.query.id, null, true);
|
||||||
const file = !playlist_id ? auth_api.getUserVideo(uuid, uid, type, true, req.body) : auth_api.getUserPlaylist(uuid, playlist_id, null, false);
|
const is_shared = file ? file['sharingEnabled'] : false;
|
||||||
if (file) {
|
if (is_shared) {
|
||||||
req.can_watch = true;
|
req.can_watch = true;
|
||||||
return next();
|
return next();
|
||||||
} else {
|
} else {
|
||||||
@@ -1991,7 +1990,7 @@ app.post('/api/getFile', optionalJwt, function (req, res) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post('/api/getAllFiles', optionalJwt, function (req, res) {
|
app.post('/api/getAllFiles', optionalJwt, async function (req, res) {
|
||||||
// these are returned
|
// these are returned
|
||||||
let files = [];
|
let files = [];
|
||||||
let playlists = [];
|
let playlists = [];
|
||||||
@@ -2549,8 +2548,7 @@ 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, req.body.uuid);
|
file = await createPlaylistZipFile(fileNames, type, outputName, fullPathProvided);
|
||||||
file = path.join(__dirname, file);
|
|
||||||
}
|
}
|
||||||
res.sendFile(file, function (err) {
|
res.sendFile(file, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
@@ -283,7 +283,6 @@ 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) {
|
||||||
@@ -398,7 +397,7 @@ exports.deleteUserFile = function(user_uid, file_uid, type, blacklistMode = fals
|
|||||||
|
|
||||||
// use subscriptions API to remove video from the archive file, and write it to the blacklist
|
// use subscriptions API to remove video from the archive file, and write it to the blacklist
|
||||||
if (fs.existsSync(archive_path)) {
|
if (fs.existsSync(archive_path)) {
|
||||||
const line = youtube_id ? subscriptions_api.removeIDFromArchive(archive_path, youtube_id) : null;
|
let line = youtube_id ? subscriptions_api.removeIDFromArchive(archive_path, youtube_id) : null;
|
||||||
if (blacklistMode && line) {
|
if (blacklistMode && line) {
|
||||||
let blacklistPath = path.join(usersFileFolder, user_uid, 'archives', `blacklist_${type}.txt`);
|
let blacklistPath = path.join(usersFileFolder, user_uid, 'archives', `blacklist_${type}.txt`);
|
||||||
// adds newline to the beginning of the line
|
// adds newline to the beginning of the line
|
||||||
|
|||||||
@@ -317,8 +317,7 @@ 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, null, null, null, null,
|
this.postsService.downloadFileFromServer(fileNames, this.type, zipName).subscribe(res => {
|
||||||
!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, id = null) {
|
uid = null, uuid = 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,8 +232,7 @@ 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