tuxfoo / lbry-seedit

A simple script to help support the lbry network and your favourite creators on it.
GNU General Public License v2.0
33 stars 10 forks source link

Delete files after downloading #5

Closed kodxana closed 3 years ago

kodxana commented 3 years ago

Delete Downloads folder after blob files gets created :)

tuxfoo commented 3 years ago

I wonder if there is a way to do this via the API https://lbry.tech/api/sdk#file_delete

tuxfoo commented 3 years ago

Maybe just check

lbrynet file list --completed=false

If it is not in this list, then we can assume the blob files are generated. I could not find a way to remove the file using the lbry API without also removing the blob files.

tuxfoo commented 3 years ago

From my testing, if a file gets deleted before it has downloaded all the blobs, the file will be just be recreated.

I do not see the harm in simply deleting all the files each time the script is run.

If that causes problems then something like this might be the solution

def clean_downloads(videos):
    for video in videos:
        if video['blobs_remaining'] == '0':
            path = '/home/lbrynet/'
            subprocess.call("rm " + path + video['metadata']['source']['name'], shell=True)
tuxfoo commented 3 years ago

For now, just delete the downloads folder. I did a few tests and it does not seem to break anything.

https://github.com/tuxfoo/lbry-seedit/commit/7d9c615494dd083fed7a45e40126c2707ca94cc5