#1361
|
||||
|
||||
![]()
No worries
![]() Thanks - I've forwarded this to the user ![]() -psp-
__________________
JD Supporter, Plugin Dev. & Community Manager Erste Schritte & Tutorials || JDownloader 2 Setup Download ----------------------------------- On Vacation / Im Urlaub Start: 2023-12-09 End: TBA |
#1362
|
|||
|
|||
![]()
That is so genius of you @mgpai.
What should the command be if the script only starts after unpacking finished the last download in the queue? Is there also a medicine? Last edited by OCHer; 12.05.2020 at 17:44. |
#1363
|
|||
|
|||
![]() Quote:
Quote:
if still curious on adding ID3v2 Tags to future downloads give this a try, it's nice to have embed metadata. Code:
//Add ID3v2 Tags to Youtube Audio Files Includes AAC* & OGG* (w/ffmpeg) //Trigger: A Download Stopped // //IMPORTANT: // must config Youtube Plugin with this preset // Goto: [Settings > Plugins > (choose) Youtube > Filename to Audio files > (copy and paste custom audio preset below here)] // Preset: [track=`*PLAYLIST_POSITION*`;title=`*TITLE*`;artist=`*USERNAME*`;album=`*PLAYLIST_NAME*`;date=`*DATE*`;.*EXT*] <--without square brackets // // add or remove ID3v2 tags pattern must follow this format: // [ffmpegKeyForID3v2Tag=`*YOUTUBE FileNames/PackageNames*`;] <--without square brackets // // ffmpegKeyForID3v2Tags found here > hxxps://gist.github.com/eyecatchup/0757b3d8b989fe433979db2ea7d95a01 // YOUTUBE FileNames/PackageNames properties are found in [Settings > Plugins > (choose) Youtube > (scroll down toward the bottom)] // //NOTE* ffmpeg cant set ID3v2 tags to some audio formats directly e.g aac&ogg but have no problems with container e.g m4a // hence this script will wrap aac&ogg file in m4a container then add ID3v2 tags that way // // After finished crawling File Name will be temporary hold Id3v2 metadata retrieved. It'll be messy at first both in DL/LG // e.g [track=`0001`;title=`Song Title (Official Video)`;artist=`Uploader Name`;album=`Playlist Name`;date=`Uploaded Date`;.aac] // Once finished downloading Id3v2 tags will be applied then custom File Name will be set as [sTrack - sTitle - sArtist - sDate] // e.g [0001 - Song Title (Official Video) - Uploader Name - Uploaded Date.acc] // //-------------------------------------------------------- disablePermissionChecks(); //no prompting persmision dialog var hoster = link.getHost(); if (hoster == 'youtube.com') { var regexAudioExt = /.+\.(aac|ogg|mp3)$/ig; //<-- add/remove audio file extensions var isFinished = link.isFinished(); var fileName = link.getName(); var fileExt = fileName.replace(regexAudioExt, '$1'); if (fileExt && isFinished && hoster == 'youtube.com') { var sTrack = ''; var sTitle = ''; var sArtist = ''; var sDate = ''; var metaData = ''; var fileDir = link.getPackage().getDownloadFolder(); var filePath = getPath(fileDir + '/' + fileName) var regexMetadata = /^(?:^|\s+)?(track|title|artist|album|date|author_url|comment|copyright)(=`.+`)(?:^|\s+)?$/ig; //<--add/remove ffmpeg keys for ID3v2 tags var regexYear = /^(date=`).+(\d{4}`)$/ig; var regexFile = /^(.*?)\..{2,4}$/ig; var string = fileName.replace(regexFile, '$1'); string.split(';').forEach(function(tag) { var tagTmp = tag; //if (regexMetadata.test(tagTmp)) { //this fails when string contains utf-8 if (tag.match(regexMetadata)) { if (regexYear.test(tag)) tagTmp = tag.replace(regexYear, '$1$2'); if (/^track=/.test(tag)) sTrack = tag.replace(/.+\=`(.+)`$/, '$1 - '); if (/^title=/.test(tag)) sTitle = tag.replace(/.+\=`(.+)`$/, '$1 - '); if (/^artist=/.test(tag)) sArtist = tag.replace(/.+\=`(.+)`$/, '$1 - '); if (/^date=/.test(tag)) sDate = tag.replace(/.+\=`(.+)`$/, '$1'); tagTmp = tagTmp.replace(/`$/g, '"'); tagTmp = tagTmp.replace(/=`/g, '="'); if (tagTmp.length) metaData += ' -metadata ' + tagTmp; } }) var m4aExt = 'm4a' var newFileName = sTrack + sTitle + sArtist + sDate + ' [' + m4aExt + ']' + '.' + fileExt //Custum final file name var m4aContainer = sTrack + sTitle + sArtist + sDate + ' [' + m4aExt + ']' + '.' + m4aExt var newFileNameWithNoID3Set = sTrack + sTitle + sArtist + sDate + '.' + fileExt //Custum final file name var m4aContainerPath = getPath(fileDir + '/' + m4aContainer); var newFilePath = getPath(fileDir + '/' + newFileName); //var ffmpeg = callAPI("config", "get", "org.jdownloader.controlling.ffmpeg.FFmpegSetup", null, "binarypath"); //download ffmpeg var ffmpeg = getPath(JD_HOME + '/tools/Windows/ffmpeg/x64/ffmpeg.exe'); var ffmpegID3Cmd = getPath(fileDir + '/setID3' + newFileName + '.cmd'); if (ffmpeg.exists() && filePath.exists()) { //Option 1 - will fail with some filename contains none ASCII chars or filename is too long. //vbs or ps1 might fix this issue. var deleteOrigFile = '\n\r' + 'del "' + filePath + '"' var deleteBatchCmd = '\n\r' + 'del "' + ffmpegID3Cmd + '"' var renameBacktoOrigExt = '\n\r' + 'ren "' + m4aContainerPath + '" *.' + fileExt //m4aExt > fileExt var windowsId3v2dot3comp = ' -id3v2_version 3 -write_id3v1 1 '; if (/.+\.(aac|ogg)$/ig.test(fileName)) { var ffmpegId3 = '"' + ffmpeg + '" -i "' + filePath + '" ' + metaData + windowsId3v2dot3comp + ' "' + m4aContainerPath + '"' //wrap audio file(s) in m4a container var cmd = ffmpegId3 + renameBacktoOrigExt + deleteOrigFile + deleteBatchCmd; } else { var ffmpegId3 = '"' + ffmpeg + '" -i "' + filePath + '" ' + metaData + windowsId3v2dot3comp + ' "' + newFilePath + '"' var cmd = ffmpegId3 + deleteOrigFile + deleteBatchCmd; } try { deleteFile(ffmpegID3Cmd, false); writeFile(ffmpegID3Cmd, cmd, false); callSync(ffmpegID3Cmd); link.setName(newFileName) } catch (e) { deleteFile(ffmpegID3Cmd, false); link.setName(newFileNameWithNoID3Set) //failed wrapping audio file in m4aExt and no Id3v2 tags applied (occurrs on some non ASCII file names/long file names) } //Option 2 - not working (inputs welcome) //callAsync(ffmpeg, '-i', filePath, '-metadata title="Test Set Title"', newFilePath); //callAsync(ffmpeg, '-i', filePath, metaData, newFilePath); } } } Last edited by zreenmkr; 13.05.2020 at 04:21. Reason: added host and container check |
#1364
|
||||
|
||||
![]()
@zreenmkr: Thanks for your great work and help on scripting!
__________________
JD-Dev & Server-Admin |
#1365
|
|||
|
|||
![]() Quote:
Code:
// Call external program // Trigger: Archive extraction finished disablePermissionChecks(); if (isDownloadControllerIdle() && !callAPI("extraction", "getQueue").length) callSync("synoindex", "-R", "video"); This should call the external program if no downloads are running and last archive file has been extracted. Install the script in JD with GUI and copy the JSON value from advanced settings. |
#1366
|
|||
|
|||
![]() Quote:
Last edited by sherif011; 17.05.2020 at 17:09. |
#1367
|
|||
|
|||
![]()
I mean, I just need to set the limit for the current session, just after I click start, without counting previous downloads.
|
#1368
|
|||
|
|||
![]()
Hi I've got a couple things I'm trying to sort out in this script. One thing I've pretty much done but I haven't got a clue how to do the second thing.
1: This script works fine, until after it runs test.exe, when that task completes the downloads don't start again...I don't understand why. 2: I want to be able to measure the interval between occurrences of the script. For example take the system time, save as a global variable, then compare that with system time the next time a download goes offline. Hope someone can help! Code:
// Script to stop, reset links, run captcha macro, restart downloads // Trigger: "A Download Stopped" var finalStatus = link.getFinalLinkStatus(); disablePermissionChecks(); if (finalStatus == "OFFLINE") { stopDownloads(); link.reset(); callSync("c:\\test.exe"); startDownloads(); } |
#1369
|
|||
|
|||
![]()
@mgpai
Hi, regarding the script that deals with Zippyshare's and general links reset, is there a way that it doesn't trigger the sleeping process if there are still pending downloads? I mean, the other day I left a bunch of files downloading and since after a while the system went to sleep, I thought all of them were downloaded, but it wasn't like that. Back when I checked, I noticed the system was put to sleep, but there were many files still not downloaded/interrupted. Thanks. Last edited by ElCho; 18.05.2020 at 14:39. Reason: typo |
#1370
|
|||
|
|||
![]() Quote:
leave the 2nd script alone, dont change anything there. because trigger is interval, it runs silently in the background every x number of mili-seconds (change that at top right corner of eventscript editor, 1000 = 1second) to check if x GB limit is met that is set by the 1st script. 1st script is a controller, allows your to enter x GB limit and also start a new session everytime you select/click on it. to activate the controller, create a button or a menu selector for it. there are 3 options for trigger described but there are also other options to do that. the 3 commonly used are Toolbar Button at the top, or add menu selector when you Right-Mouse-Click or in the Main menu. here is the tutorial, But the easiest way is after you set trigger to e.g 'Toolbar Button Pressed', go back into eventscripter editor, there is now a button at the top call 'Main Toolbar', click on that, follow the tutorial above to create a button. rename 'Event Scripter' to 'Start Monitor Loaded Bytes' Last edited by zreenmkr; 18.05.2020 at 04:04. |
#1371
|
|||
|
|||
![]() Quote:
Code:
//Trigger: Downloadlist ContextMenu Button Pressed if (name == 'CheckLink Status') { try { link = lgSelection.getContextLink(); } catch (e) {} try { link = dlSelection.getContextLink(); } catch (e) {} var lnkStatus1 = link.getStatus(); var lnkStatus2 = link.getFinalLinkStatus(); alert('status1: ' + lnkStatus1 + '\nstatus2: ' + lnkStatus2); } Quote:
alternatively if you know why your files skip downloading or go offline frequently, you can also use trigger Interval and check every links every x minutes. Adapt this script to your own needs Last edited by zreenmkr; 18.05.2020 at 07:11. |
#1372
|
|||
|
|||
![]() Quote:
Also, your issue might be the same with @MrBojangles_ see above for solutions |
#1373
|
|||
|
|||
![]() Quote:
Code:
// Limit per download session // Trigger: Download Controller Started var limit = 20; // <- Session limit (GB) var interval = 30; // <- Interval between checks (seconds) var getLoadedBytes = function() { return callAPI("polling", "poll", { "aggregatedNumbers": true })[0].eventData.data.loadedBytes; } var loadedBytes = getLoadedBytes(); while (isDownloadControllerRunning() || isDownloadControllerPaused()) { sleep(interval * 1000); if ((getLoadedBytes() - loadedBytes) / 1e9 > limit) stopDownloads(); } |
#1374
|
|||
|
|||
![]() Quote:
Quote:
Code:
var myObject = setProperty(myString/*"key"*/, myObject/*anyValue*/, myBoolean/*global(boolean)*/);/*Set a Property. This property will be available until JD-exit or a script overwrites it. if global is true, the property will be available for al scripts*/ /* Example: */var oldValue=setProperty("myobject", { "name": true}, false); var myObject = getProperty(myString/*"key"*/, myBoolean/*global(boolean)*/);/*Get a Property. Set global to true if you want to access a global property*/ /* Example: */var value=getProperty("myobject", false); |
#1375
|
||||
|
||||
![]() Quote:
Before the script runs, the download that failed (/triggered the captcha) is OFFLINE. After the link resets then it goes back to UNKNOWN. Putting it after running the external program doesn't seem to change anything, except resetting the link later. The downloads still don't restart Does startDownloads() not do anything if the links are UNKNOWN? Quote:
Quote:
Quote:
Last edited by MrBojangles_; 18.05.2020 at 14:22. Reason: Answered one of my own questions... |
#1376
|
|||
|
|||
![]() Quote:
If you post the log ID of that session and also provide the urls of the links which fail to start, the developers might be able to check it and provide more information. |
#1377
|
|||
|
|||
![]() Quote:
I'm moving onto problem two now, I have tried to set a global variable that I can recall later, using the commands you showed: Code:
FirstTime = typeof(FirstTime) == 'undefined' ? 0 : FirstTime; setProperty(FirstTime, {"stamp":Date.now()}, true); var RetrievedTimeStamp = getProperty(FirstTime, true); alert(RetrievedTimeStamp.stamp); Last edited by MrBojangles_; 18.05.2020 at 16:31. Reason: More testing. |
#1378
|
|||
|
|||
![]() Quote:
Code:
while (!isDownloadControllerIdle()) sleep(1000); Should work, assuming some other link/script will not try to start the download in the meanwhile. Quote:
"key" should be "String" Code:
if (getProperty("FirstTime", true) === null) { setProperty("FirstTime", { "stamp": Date.now() }, true); } var RetrievedTimeStamp = getProperty("FirstTime", true); alert(RetrievedTimeStamp.stamp); |
#1379
|
|||
|
|||
![]() Quote:
It did create a new problem with the script being triggered repeatedly before the first iteration stopped downloads but I figured a way round that. Quote:
Everything is now working beautifully, thank you so much for your help! |
#1380
|
|||
|
|||
![]() Quote:
Quote:
![]() |
![]() |
Thread Tools | |
Display Modes | |
|
|