mirror of
https://git.lecygnenoir.info/LecygneNoir/prismedia.git
synced 2025-10-03 09:29:16 +02:00
Add an option to use some credits easiely
This tells youtube the apikey is still used and they should not remove all of the quota.
This commit is contained in:
parent
9b6da1e3dc
commit
a725e848ab
2 changed files with 25 additions and 0 deletions
|
@ -7,6 +7,7 @@ prismedia - tool to upload videos to Peertube and Youtube
|
|||
Usage:
|
||||
prismedia --file=<FILE> [options]
|
||||
prismedia -f <FILE> --tags=STRING [options]
|
||||
prismedia --hearthbeat
|
||||
prismedia -h | --help
|
||||
prismedia --version
|
||||
|
||||
|
@ -50,6 +51,9 @@ Options:
|
|||
--playlistCreate Create the playlist if not exists. (default do not create)
|
||||
Only relevant if --playlist is set.
|
||||
--progress=STRING Set the progress bar view, one of percentage, bigFile (MB), accurate (KB).
|
||||
|
||||
--hearthbeat Use some credits to show some activity for you apikey so the platform know it is used and would not put your quota to 0 (only Youtube currently)
|
||||
|
||||
-h --help Show this help.
|
||||
--version Show version.
|
||||
|
||||
|
@ -396,11 +400,17 @@ def main():
|
|||
Optional('--playlist'): Or(None, str),
|
||||
Optional('--playlistCreate'): bool,
|
||||
Optional('--progress'): Or(None, And(str, validateProgress, error="Sorry, progress visualisation not supported")),
|
||||
'--hearthbeat': bool,
|
||||
'--help': bool,
|
||||
'--version': bool,
|
||||
# This allow to return all other options for further use: https://github.com/keleshev/schema#extra-keys
|
||||
object: object
|
||||
})
|
||||
|
||||
if options.get('--hearthbeat'):
|
||||
yt_upload.hearthbeat()
|
||||
exit(0)
|
||||
|
||||
# We need to validate early options first as withNFO and logs options should be prioritized
|
||||
try:
|
||||
options = earlyoptionSchema.validate(options)
|
||||
|
|
|
@ -331,6 +331,21 @@ def resumable_upload(request, resource, method, options):
|
|||
time.sleep(sleep_seconds)
|
||||
|
||||
|
||||
def hearthbeat():
|
||||
"""Use the minimums credits possibles of the API so google does not readuce to 0 the allowed credits.
|
||||
This apparently happens after 90 days without any usage of credits.
|
||||
For more info see the official documentations :
|
||||
- General informations about quotas : https://developers.google.com/youtube/v3/getting-started#quota
|
||||
- Quota costs for API requests : https://developers.google.com/youtube/v3/determine_quota_cost
|
||||
- ToS (Americas) #Usage and Quotas : https://developers.google.com/youtube/terms/api-services-terms-of-service#usage-and-quotas"""
|
||||
youtube = get_authenticated_service()
|
||||
try:
|
||||
get_playlist_by_name(youtube, "Foo")
|
||||
except HttpError as e:
|
||||
logger.error('Youtube : An HTTP error %d occurred on hearthbeat:\n%s' %
|
||||
(e.resp.status, e.content))
|
||||
|
||||
|
||||
def run(options):
|
||||
youtube = get_authenticated_service()
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue