Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exec on skipped files #992

Closed
God-damnit-all opened this issue Sep 12, 2020 · 4 comments
Closed

exec on skipped files #992

God-damnit-all opened this issue Sep 12, 2020 · 4 comments

Comments

@God-damnit-all
Copy link
Contributor

I'm interested in scraping Twitter with retweets, but I don't want to have to constantly redownload the same files from artists retweeting one another.

What I would like to do is, after each download, run a command for copying the file to a different directory structure (or creating a symbolic link). The only problem is exec only runs on files that are downloaded. If it skips a file, no command will be ran.

What I would like is an option to exec on skipped files, exec on downloaded files, or exec on both.

@God-damnit-all
Copy link
Contributor Author

As an aside, if anyone can figure out how to do this with manually editing the code in the meantime, please let me know. Every tweak to the code I've tried has failed spectacularly.

@mikf
Copy link
Owner

mikf commented Sep 13, 2020

For exec specifically, you can replace handle_skip() with the following and it should more or less work:

    def handle_skip(self):
        self.out.skip(self.pathfmt.path)
        if self.postprocessors:
            for pp in self.postprocessors:
                pp.run_after(self.pathfmt)
        if self._skipexc:
            self._skipcnt += 1
            if self._skipcnt >= self._skipmax:
                raise self._skipexc()

@God-damnit-all
Copy link
Contributor Author

For exec specifically, you can replace handle_skip() with the following and it should more or less work:

    def handle_skip(self):
        self.out.skip(self.pathfmt.path)
        if self.postprocessors:
            for pp in self.postprocessors:
                pp.run_after(self.pathfmt)
        if self._skipexc:
            self._skipcnt += 1
            if self._skipcnt >= self._skipmax:
                raise self._skipexc()

I just realized I forgot to thank you for this. Thank you.

You should really set up the ability to receive donations through GitHub, I'd gladly send you a fiver every month.

@mikf
Copy link
Owner

mikf commented Nov 25, 2020

9c3568c makes it is possible to use the following to run a command on skipped files:

{
    "name": "exec",
    "event": "skip",
    "command": "..."
}

To run it for both skipped and newly downloaded files, use "event": "file,skip"

@mikf mikf closed this as completed Nov 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants