youtube-upload icon indicating copy to clipboard operation
youtube-upload copied to clipboard

oauth.json is deleted after upload

Open Esokrates opened this issue 3 years ago • 4 comments
trafficstars

Problem

My directory looks like this:

client_secrets.json  oauth.json test.mp4  test.py

and test.py like this:

from youtube_upload.client import YoutubeUploader

uploader = YoutubeUploader()
uploader.authenticate()

# Video options
options = {
    "title" : "Example title", # The video title
    "description" : "Example description", # The video description
    "categoryId" : "22",
    "privacyStatus" : "private", # Video privacy. Can either be "public", "private", or "unlisted"
    "kids" : False, # Specifies if the Video if for kids or not. Defaults to False.
}

# upload video
uploader.upload("./test.mp4", options)
uploader.close()

After running test.py the oauth.json file is deleted for some reason, but I would like too keep it in order not to have authenticate everytime I use the script.

Esokrates avatar Jan 29 '22 11:01 Esokrates

This is the code you are referring to.

https://github.com/pillargg/youtube-upload/blob/cc85eedc553aa31f060cfb113976fe7d5b62ecbb/youtube_upload/client.py#L317-L322

If you do not call uploader.close() it will not delete the file. Our upload procedure requires us to delete the file, so we added the close functionality. I will clarify the documentation.

chand1012 avatar Feb 01 '22 00:02 chand1012

I'm not calling the uploader.close and it deletes the file anyway? I have to set it to read only. I don't quite understand why does the script do this?! My code looks like this at the end:

uploader.authenticate("files/oauth.json")
print(f'[{video_id}]: Uploading...')
uploader.upload(file_path, options)
print(f'[{video_id}]: Upload successful.')
print(f'[{video_id}]: Done.')

1ukastesar avatar Feb 11 '22 16:02 1ukastesar

the file is indeed deleted even if you don't call the close() function, what is happening ?

flazouh avatar Mar 05 '22 01:03 flazouh

The problem is with the __del__ method here. __del__ is a finalizer and it is called when the object is garbage collected. So, at the end of the run it will delete the file, either you want or not. I think this is bug. In any case I have commented it in my local copy and things are alright.

edumucelli avatar May 31 '22 22:05 edumucelli