Ejemplo n.º 1
0
def get_youtube_handler(options):
    """Return the API Youtube object."""

    home = os.getcwd()
    # home = os.path.expanduser("~")
    default_credentials = os.path.join(home, "youtube-upload-credentials.json")
    client_secrets = options.client_secrets or os.path.join(home, "client_secrets.json")
    credentials = options.credentials_file or default_credentials
    debug("Using client secrets: {0}".format(client_secrets))
    debug("Using credentials file: {0}".format(credentials))
    get_code_callback = (auth.browser.get_code
        if options.auth_browser else auth.console.get_code)
    return auth.get_resource(client_secrets, credentials,
        get_code_callback=get_code_callback)
Ejemplo n.º 2
0
def get_youtube_handler(options=None):
    """Return the API Youtube object."""
    home = os.path.expanduser("~")
    default_client_secrets = lib.get_first_existing_filename(
        [sys.prefix, os.path.join(sys.prefix, "local")],
        "share/youtube_upload/client_secrets.json")  
    default_credentials = os.path.join(home, ".youtube-upload-credentials.json")
    client_secrets = default_client_secrets or \
        os.path.join(home, ".client_secrets.json")
    credentials = default_credentials
    lib.debug("Using client secrets: {0}".format(client_secrets))
    lib.debug("Using credentials file: {0}".format(credentials))
    get_code_callback = (auth.browser.get_code 
        if options==None else auth.console.get_code)
    return auth.get_resource(client_secrets, credentials,
        get_code_callback=get_code_callback)
Ejemplo n.º 3
0
def get_youtube_handler(options):
    """Return the API Youtube object."""
    cs_name = "client_secrets.json"
    cred_name = "youtube-upload-credentials.json"
    home = os.path.expanduser("~")
    default_client_secrets = lib.get_standard_filename(cs_name)
    default_credentials = os.path.join(os.path.dirname(default_client_secrets),
        cred_name)
    client_secrets = options.client_secrets or default_client_secrets or \
        os.path.join(home, ".client_secrets.json")
    credentials = options.credentials_file or default_credentials
    debug("Using client secrets: {0}".format(client_secrets))
    debug("Using credentials file: {0}".format(credentials))
    get_code_callback = (
        auth.browser.get_code if options.auth_browser
        else auth.console.get_code
    )
    return auth.get_resource(
        client_secrets, credentials, get_code_callback=get_code_callback)