Topic: e621-md5-tagger on GitHub

Posted under e621 Tools and Applications

Why not print the contents of those two files to the terminal so people don't have to manually open the files if they don't want to use their browser.

Updated by anonymous

mrox said:
Why not print the contents of those two files to the terminal so people don't have to manually open the files if they don't want to use their browser.

To be completely honest, I wouldn't know how to format the output of the script into something human-readable. Maybe savageorange would know... The link to his e621 profile should be at the bottom of the GitHub README.md file.

Updated by anonymous

And while doing so, breaking the master... crap.
EDIT: the master has been fixed.

Updated by anonymous

Add: cat /var/www/myimouto/public/e6tags.txt

To the bottom of the op.sh file. That'll print the file to the command line. It doesn't need to be pretty.

Updated by anonymous

^ Though it's not hard to make it prettier than that, using tr to turn the space characters into newlines.

It seems like you might even be able to get jq to do this for you, using reduce function. see the advanced features section of the manual

@OP: good job commenting it. I see you picked up on how to append text to a file.
It's probably possible to do the whole thing with one line (getting jq to grab and format both of the relevant bits of information in one go), with some research.
Another minor comment is that ; is simply a command separator, therefore :

filename="$(zenity --file-selection)"
wget -O - 'https://e621.net/post/index.json?tags=md5:'$(md5sum "$filename" | cut -d ' ' -f 1) | jq --raw-output '.[0].id' - > /var/www/myimouto/public/e6tags.txt

is exactly equivalent to filename="$(zenity --file-selection)"; wget -O - 'https://e621.net/post/index.json?tags=md5:'$(md5sum "$filename" | cut -d ' ' -f 1) | jq --raw-output '.[0].id' - > /var/www/myimouto/public/e6tags.txt, which is may be relevant to readability.

Other possible concessions to readability might include storing the md5sum .. cut output instead of using inline process-expansion, and storing the destination as a variable rather than constant:

destination="/var/www/myimouto/public/e6tags.txt"
filename="$(zenity --file-selection)"
md5=$(md5sum "$filename" | cut -d ' ' -f 1)
wget -O - "https://e621.net/post/index.json?tags=md5:$md5" | jq --raw-output '.[0].id' - > "$destination"

Updated by anonymous

  • 1