Browse Source

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.
pull/54/head
Zykino 3 years ago
parent
commit
a725e848ab
2 changed files with 25 additions and 0 deletions
  1. +10
    -0
      prismedia/upload.py
  2. +15
    -0
      prismedia/yt_upload.py

+ 10
- 0
prismedia/upload.py View File

@ -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)

+ 15
- 0
prismedia/yt_upload.py View File

@ -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…
Cancel
Save