allejok96 / jw-scripts

Index or download videos and sound recordings from jw.org.
GNU General Public License v3.0
49 stars 10 forks source link

Use of --latest flag deleting links #10

Closed leejk421 closed 6 years ago

leejk421 commented 6 years ago

Hello,

Thanks for writing this script! So after running the command to download everything from July 1 of this year, I now have a directory of videos in the jwb-E folder, and a symlink to a directory named Video on Demand, with symlinks to other folders within it. Looks good. However, when I later run the below command using the latest flag, it deletes all the symlinks? Should it not just delete ones that are no longer pointing to valid video files?

1rst run - jwb-index --download --since 2017-07-01 --mode filesystem --free 275000 /Users/leejk/jw_broadcasting

2nd run - jwb-index --latest --download --mode filesystem --free 275000 /Users/leejk/jw_broadcasting

My goal is to set this up as an Automator job after getting the initial download. As a feature request, would it be possible to enable logging for the script to capture all of the output when used in an automated process?

allejok96 commented 6 years ago

Thanks for taking time and filling in the bug reports. Must find some better way to test the scripts before releasing. I have identified the problem and will fix it later.

But what do you mean by logging and "all of the output"? Like all files/links created or more info about what is indexed or what? Or more warnings when something's not right, which I know is lacking a bit...

leejk421 commented 6 years ago

Sounds good. For logging, just basic logging is fine. I was just wanting the scripts console output written to a file. I tried dumping the output by using the > redirect operator, but it wouldn't work for some reason. Could be my error. Ideally I'd like to capture errored or successful runs from your script, then have Automator send me an email on failures. Something like this poster is doing: https://stackoverflow.com/questions/22520948/how-to-view-stdout-of-script-run-within-automator But I know nothing of Python.

allejok96 commented 6 years ago

The automator job you have would have generated a log file with only the category names, VODChildren and so on if I understand it correctly... Now I know nothing about macOS, but I think it's shell is bash. So in bash you would do 2> to send standard error messages aka stderr to a file or &> to send both stdout and stderr.

So the output is good enough for you already? The problem was just getting it into a file, right?

Now I've fixed the symlinking issue, please try it out again.

I've also added (back - it existed some time ago) a --clean flag. It will clean out all symlinks like before. Why? Well, the "Latest Videos" will just keep adding up forever.... So once in a while, run a new full re-index with --clean to tidy things up.

leejk421 commented 6 years ago

Working fine now.