JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1  
Old 26.04.2024, 23:52
tb21 tb21 is offline
Super Loader
 
Join Date: Oct 2021
Posts: 26
Default "Create Text File" in LinkGrabber..

Hello everyone! o)

If you paste a playlist (e.g.) into the link grabber and it creates a package with some links to download, how could I add/create another file to the package containing additional event and artist information, which is not available as an URL?

A complex solution would be: Use context menu event, open editor, insert text, save to local webserver and add local URL to the package via scripting. Maybe there is an easier way?

I basically only need a "Create Text File" option or context menu in the link grabber.

Thanks you in advance!
Have a nice weekend! o)
Reply With Quote
  #2  
Old 27.04.2024, 00:51
tb21 tb21 is offline
Super Loader
 
Join Date: Oct 2021
Posts: 26
Default

I just searched through all the available js functions and objects, there is no way to add a link to a package in the link grabber, or is there?

This would mean my complex solution would be even more complex, since I need to create a crawl job for the local webserver link and maybe auto-merge the package popping up in the link grabber from the crawl job, with the one I already have.

Maybe I overcomplicate things? I don't know.. o)
Reply With Quote
  #3  
Old 27.04.2024, 10:22
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,578
Default

Quote:
Originally Posted by tb21 View Post
I basically only need a "Create Text File" option or context menu in the link grabber.
Create a context menu script to:
  1. create an empty text file in the same folder (generate name from right-clicking on existing link e.g: downloadFolder/link.name.txt).
  2. open it in text editor (synhronous) add content save/exit.
  3. Add the new text file path to linkgrabber using addLinks method. Use the same package name in the addLinksQuery to add to the same pacakge.
Reply With Quote
  #4  
Old 27.04.2024, 12:25
tb21 tb21 is offline
Super Loader
 
Join Date: Oct 2021
Posts: 26
Default

Hello mgpai! o)

thank you! I just stumbled upon this code, by using the search:
Code:
callAPI("linkgrabberv2", "addLinks", {
    links: content
});
I guess that's what you mean? I was looking through the expandable "help" section in the script dialog, could not find anything like that. Is there a reference for these kind of API calls somewhere?

Thank you, your suggestion sounds very promising, I will try! o)
Have a nice weekend! o)
Reply With Quote
  #5  
Old 27.04.2024, 12:30
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,578
Default

Quote:
Originally Posted by tb21 View Post
I was looking through the expandable "help" section in the script dialog, could not find anything like that. Is there a reference for these kind of API calls somewhere?
It is a MYJD API call, which can be used in eventrscripter using callAPI method.
Reply With Quote
  #6  
Old 27.04.2024, 12:38
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 80,387
Default

Quote:
Originally Posted by mgpai View Post
It is a MYJD API call, which can be used in eventrscripter using callAPI method.
I will add the link to the command description with next update
__________________
JD-Dev & Server-Admin
Reply With Quote
  #7  
Old 27.04.2024, 12:41
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 80,387
Default

@tb21: please know that you cannot add *Fake/dummy* links that way. In case you only want to store additional data, best would be to store them in comment/properties of the link and have a script write them on disk after download is finished

You can also make use of Packagizer, see https://support.jdownloader.org/de/k...the-packagizer and append stuff to the link directly and modify filenames/other stuff/access it in scripts.
__________________
JD-Dev & Server-Admin
Reply With Quote
  #8  
Old 27.04.2024, 13:36
tb21 tb21 is offline
Super Loader
 
Join Date: Oct 2021
Posts: 26
Default

Woohoo! o)
Nice reference, how come I haven't seen this one before? Will dive into that one for sure! o)

Quote:
I will add the link to the command description with next update
Good idea, appreciated! o)

Putting my extra metadata into a property is a nice idea! I used properties before, to "communicate" processing status between scripts, sounds like a proper solution compared to generating links and files on a local webserver or something - awesome! o)

It's good I asked! o)

I'm not sure how the Packagizer could help when trying to add meta data "from the side" to an existing package? Please elaborate if you find the time, appreciate any input! o), but I think putting things into a property and dumping that later is fine for me now.

Ok, I did not plan to generate "fake links", but what about links to local files, using the file:// protocol? That probably doesn't work hu? Just another idea I had, after seeing the "addLinks" possibility (reading a local file would be easier than integrating a local webserver), but I think we have a better solution anyway now.

The property solution has just one down-side, meta data added will not be visible until the download script is done. Maybe I add another "View/Edit/Export Meta" context menu here and there, that could work.

Thanks everone! o)
Reply With Quote
  #9  
Old 27.04.2024, 13:54
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 80,387
Default

Quote:
Originally Posted by tb21 View Post
I'm not sure how the Packagizer could help when trying to add meta data "from the side" to an existing package? Please elaborate if you find the time, appreciate any input! o), but I think putting things into a property and dumping that later is fine for me now.
The idea was to place meta info into links and access/process them within your script in eventscipter. sometimes ppl just want to add stuff to filename of foldername, then packagizer alone would be possible to do so.heavily depends on what you're trying to achieve.

file protocol is not supported, but nice idea. but in fact maybe a sort of dummy file/link would be better approach here. custom protocol and have the information hex/base64 coded into url, eg an encoded json. of course you could also just add a non working link as well, eg something to local ip resulting in 404 or error
__________________
JD-Dev & Server-Admin

Last edited by Jiaz; 27.04.2024 at 13:57.
Reply With Quote
  #10  
Old 27.04.2024, 14:02
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 80,387
Default

Quote:
Originally Posted by tb21 View Post
(reading a local file would be easier than integrating a local webserver), but I think we have a better solution anyway now.
You only want fake downloads that write a text/string to disk, right? maybe we could add another type in eventscripter, so the local api can have custom endpoints defined by scripts so the script handles the http request and can serve response to it. that way you can add dummy links to localhost api. Or, instead of using the web, have a special plugin that can be triggered via faker urls, for example
script://script ID and the download wwill then trigger/execute the script. so you add script//id and give it a name and properties and when being downloaded, it will be executed and you either do something or return content that you want to be written to file.
what do you think about that?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #11  
Old 27.04.2024, 14:14
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,578
Default

@tb21,

My suggestion was based on the assumption that you will be running a local server. You can add the created file to JD and move it download list.When the download starts a file exists check will detect that the files exists on disk and skip it (based on your setting).

I sometimes use it to add local files downloaded with other apps to maintain a list of related files for future rerference in JD.
Reply With Quote
  #12  
Old 27.04.2024, 15:29
tb21 tb21 is offline
Super Loader
 
Join Date: Oct 2021
Posts: 26
Default

Interesting talk with you guys.. thanks! o)

@mgpai and @Jiaz
Integrating a local webserver is something I'd like to avoid, it's not that I don't have one at hand, but it would raise complexity quite a bit, especially in the future once I separated all things into proper VMs, containers etc.. But just assuming we use a local webserver, why do you suggest moving the "extra" link to the download list separately? Wouldn't that happen automatically once I start the download of the package (for which I added the extra link beforehand)?

@Jiaz and @mgpai
Yes, I kind of want to create a "fake" download on the fly for the package already in the link grabber. If things are setup as I like, I would simply start the package download and forget about it, knowing that once the whole package is downloaded, the extra meta data file will be in there too. After starting a package download from the link grabber, I would start working on the next package right there, add extra meta data, start download and repeat. That was my idea - kind of. o)

Being able to add custom type of links sounds interesting. It would be more of a generic approach I guess, if you add custom protocols / prefixes for "fake-downloads", there could be..
Code:
textfile://<linkfilename>.txt/textcontent-here-encoded-maybe
textfile://{"path": "<pkgpath>/<linkfilename>.txt", "text": "textcontent-here" }

Adding something like..
Code:
script://{"name": "scriptname", "trigger(?)": "Package finished", "payload": "text-content" }
..would be more complex I guess, but probably be more flexible. You'd need to make sure to be able to pass the payload through to the actual script, decide whether the script needs to be registered or even load it externally? If it's listed, does an existing trigger setting get in conflict with what's given in the protocol-"uri"?!

Wild guessing! o)

Either way, sounds like a lot of work on the brain and keyboard to me! o) I'm happy to share my thoughts on this.

Another (more simple?) way could be to directly copy & paste files from file manager into the link grabber package and hold them as reference as long as the download is not started. If started, instantly copy the files into the download package path. You could do this right away when doing the "paste", but this would break the existing concept of setting up a package first, maybe renaming it along the way, until you eventually start the download. If you copy on "paste" immediately, some sync would need to happen with "half" the package in the download list and the link grabber (changed name e.g.).

Being able to paste text or a an image (screenshot from clipboard e.g.) directly into the link grabber package would fit into the "copy and paste" functionality. Some file managers already automatically create a "Clipboard Text.txt" file if you hit CTRL-V and there is text in the clipboard. For images a file called "Clipboard Image.png" would be created.

You "just" need to hold that data somewhere until the download starts and yes, add some "dummy download" which handles all that.

Sorry.. lot's of text, but once you started brainstorming, I could not help.. o)

Thank you!
Reply With Quote
  #13  
Old 27.04.2024, 15:34
tb21 tb21 is offline
Super Loader
 
Join Date: Oct 2021
Posts: 26
Default

Idea: What about making use of the "Hoster" concept for this?

"Local File Hoster" for the directly copied and pasted files from the filesystem.
"Clipboard Data Hoster" for the data pasted from clipboard.

I don't know JD internals, but maybe this could be part of the concept.

EDIT: Using a specific "Hoster" would make it quite clear, where specific files originate from in the link grabber and in the download list package as well.

Last edited by tb21; 27.04.2024 at 15:37.
Reply With Quote
  #14  
Old 27.04.2024, 15:52
tb21 tb21 is offline
Super Loader
 
Join Date: Oct 2021
Posts: 26
Default

Using the Hoster concept would also allow an "Online Check" for the files being pasted, to make sure they still exist when the download is about to start. You could handle that similar to "offline links", ask a question what to do: "Move to download list anyway?" etc..

The Hoster concept offers a nice place for settings as well. The "Local File Hoster" and the "Clipboard Data Hoster" could have settings to create temporary files, instead of referencing the files to be added. That way they cannot be "offline" and also would allow deletion of (temporarily created) local files, which were used to prepare the package in the link grabber. Maybe also an option to always delete the files being pasted into the link grabber package for easier cleanup. o)

The "Clipboard Data Hoster" could offer some patterns on how to automatically name the text/image data when they get added to the package via "paste" (think of something like <package-name>_textmeta<number>.txt, where <number> would increase with every "paste" of text you do). Maybe also allow where to store the data temporarily e.g. (it might make sense to temporarily store huge "paste" data in the filesystem until the download eventually started and all this can be "dumped" into the download list package folder).
Reply With Quote
  #15  
Old 27.04.2024, 16:41
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,578
Default

@tb21,

Your requirement was to create a text file and insert it in linkgrabber. Since JD does not support 'file://' protocol, currently the only way to do it is using web server. The only puprose of running the web server is to make the created text file appear in the same package as a link. Nothing more. So baiscally it is used only during 'linkcheck'.

As to moving the link separately, no, I am not suggesting that. What I mean is when you move the package to download list, JD will attempt to download the 'created' file, which is not really neccessary. Since the file already exists on the disk you con configure JD to skip the file and mark it as finished.

If you just need to create a file in the same folder for reference, you can use a script to create/edit/view it, both in download/linkgrabber tabs.

Code:
/*
    add/view/edit notes
    trigger : linkrabber context menubutton pressed
*/

if (name == "myNotes") {
    var package = lgSelection.getContextPackage();

    if (package) {
        var notes = getPath(package.downloadFolder + "/notes.txt");

        if (!notes.exists()) {
            writeFile(notes, "", false);
        }

        callSync("notepad.exe", notes);
    }
}
Reply With Quote
  #16  
Old 27.04.2024, 19:29
tb21 tb21 is offline
Super Loader
 
Join Date: Oct 2021
Posts: 26
Default

Quote:
Since the file already exists on the disk you con configure JD to skip the file and mark it as finished.
Yes, but it is located somewhere totally different then, somewhere in the web server folder hierarchy. How would simply skipping the download make that file appear next to the other downloaded files?

I think trying to get around downloading the file from the webserver ruins the nice consistent workflow there is, it's also not an expensive operation to download a text file locally. I still might be missing an important detail, sorry, but maybe you also understand my point of view?! o)

Quote:
If you just need to create a file in the same folder for reference, you can use a script to create/edit/view it, both in download/linkgrabber tabs.
Ok, but while in the link grabber "stage", there is no folder yet, there only is a save-to path. I could use that and "early create" a file in there, but that would mean, I cannot edit the package name from that point on. If I do, things will end up in different folders.

So, I'm not so sure working around the established processes for preparing and downloading a package really adds any comfort. I think handling the "extra" link like any other seems like a sensible approach?

Thanks! o)
Reply With Quote
  #17  
Old 27.04.2024, 21:32
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 80,387
Default

I'm doing some tests with file:// *hoster* support, so you can add files to list and *download*-> copy them. also doing some tests with script://ScriptID and scriptID references to a script in Eventscripter with given ID and special type (eg fake download). and script then provides callbacks for linkcheck/download and other stuff.
don't know yet if those will make into JDownloader and for file, not knowing yet how to handle file protocol as you don't want JDownloader to grab/add every link that you just copy/pasted around in file explorer
__________________
JD-Dev & Server-Admin
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 22:20.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.