Skip to content

Commit

Permalink
[bot] Lint files
Browse files Browse the repository at this point in the history
  • Loading branch information
deepsource-autofix[bot] committed Jan 18, 2021
1 parent d1eba93 commit ad1f54b
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions youtube_upload/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def __init__(
'.',
CLIENT_SECRETS_FILE)):
'''
Initialization Function for the class.
Initialization Function for the class.
The variables `client_id` and `client_secret` can be passed in when the class is initialized, this will have the function generate the `client_secrets.json` file.
The variables `client_id` and `client_secret` can be passed in when the class is initialized, this will have the function generate the `client_secrets.json` file.
If you do not pass the variables in, the class will look for a `client_secrets.json` file in the same direction in which the script is being initialized. You can instead
pass in a directory to where the `client_secrets.json` is with the parameter `secrets_file_path` here is an example `client_secrets.json` file:
Expand Down Expand Up @@ -93,7 +93,11 @@ def __del__(self):
self.close()

# This is if you have another OAuth file to use
def authenticate(self, oauth_path=OAUTH_FILE, access_token=None, refresh_token=None):
def authenticate(
self,
oauth_path=OAUTH_FILE,
access_token=None,
refresh_token=None):
'''
This method authenticates the user with Google's servers. If you give no path, the method will look for the `oauth.json` file in the current working directory.
Expand All @@ -116,8 +120,7 @@ def authenticate(self, oauth_path=OAUTH_FILE, access_token=None, refresh_token=N
'access_token': access_token,
'refresh_token': refresh_token,
'client_id': self.client_secrets['web'].get('client_id'),
'client_secret': self.client_secrets['web'].get('client_secret')
}
'client_secret': self.client_secrets['web'].get('client_secret')}
oauth_json_str = oauth_template.substitute(subs)
with open(self.oauth_path, 'w') as f:
f.write(oauth_json_str)
Expand All @@ -142,7 +145,7 @@ def authenticate(self, oauth_path=OAUTH_FILE, access_token=None, refresh_token=N

def upload(self, file_path, options=None, chunksize=(-1)):
'''
This uploads the file to YouTube. The only required argument is the `file_path`, which is the path to the video to be uploaded.
This uploads the file to YouTube. The only required argument is the `file_path`, which is the path to the video to be uploaded.
The `options` parameter is a dictionary of options. The items are pretty self explanatory, here is an example options dictionary:
```Python
Expand All @@ -158,12 +161,12 @@ def upload(self, file_path, options=None, chunksize=(-1)):
}
```
The parameter, `chunk_size` is the max size of the HTTP request to send the video. This parameter is in bytes, and if set to `-1`, which is the default, it
will send the video in one large request. Set this to a different value if you are having issues with the upload failing.
The parameter, `chunk_size` is the max size of the HTTP request to send the video. This parameter is in bytes, and if set to `-1`, which is the default, it
will send the video in one large request. Set this to a different value if you are having issues with the upload failing.
You can also add a callback function for the case where the upload were to fail. This is mainly for custom error handling and prompting users to re-authenticate.
You can also add a callback function for the case where the upload were to fail. This is mainly for custom error handling and prompting users to re-authenticate.
The callback function is the parameter `noauth_callback`. The function passed should be able to accept a tuple of arguments. The parameter `noauth_args` is the arguments for the function. Here
The callback function is the parameter `noauth_callback`. The function passed should be able to accept a tuple of arguments. The parameter `noauth_args` is the arguments for the function. Here
is an example of the callback function being used.
```Python
Expand Down

0 comments on commit ad1f54b

Please sign in to comment.