diff --git a/prismedia/upload.py b/prismedia/upload.py index 7220b7d..2ed5283 100755 --- a/prismedia/upload.py +++ b/prismedia/upload.py @@ -7,6 +7,7 @@ prismedia - tool to upload videos to Peertube and Youtube Usage: prismedia --file= [options] prismedia -f --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) diff --git a/prismedia/yt_upload.py b/prismedia/yt_upload.py index 22db640..d050336 100644 --- a/prismedia/yt_upload.py +++ b/prismedia/yt_upload.py @@ -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: