Skip to content

Commit 2c2518a

Browse files
"Updating samples to reflect recent changes."
1 parent bb8c2a8 commit 2c2518a

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

python/unset_watermark.py

+14-16
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@
1212
from apiclient.errors import HttpError
1313
from oauth2client.file import Storage
1414
from oauth2client.client import flow_from_clientsecrets
15-
from oauth2client.tools import run
16-
from optparse import OptionParser
15+
from oauth2client.tools import argparser, run_flow
1716

1817

1918
# CLIENT_SECRETS_FILE, name of a file containing the OAuth 2.0 information for
2019
# this application, including client_id and client_secret. You can acquire an
21-
# ID/secret pair from the API Access tab on the Google APIs Console
22-
# http://code.google.com/apis/console#access
20+
# ID/secret pair from the API Access tab on the Google Developers Console
21+
# https://console.developers.google.com/project/_/apiui/credential
2322
# For more information about using OAuth2 to access Google APIs, please visit:
2423
# https://developers.google.com/accounts/docs/OAuth2
2524
# For more information about the client_secrets.json file format, please visit:
@@ -39,16 +38,16 @@
3938
To make this sample run you will need to populate the client_secrets.json file
4039
found at:
4140
%s
42-
with information from the APIs Console
43-
https://developers.google.com/console
41+
with information from the Developers Console
42+
https://console.developers.google.com
4443
4544
For more information about the client_secrets.json file format, please visit:
4645
https://developers.google.com/api-client-library/python/guide/aaa_client_secrets
4746
""" % os.path.abspath(os.path.join(os.path.dirname(__file__),
4847
CLIENT_SECRETS_FILE))
4948

5049
# Authorize the request and store authorization credentials.
51-
def get_authenticated_service():
50+
def get_authenticated_service(args):
5251
flow = flow_from_clientsecrets(CLIENT_SECRETS_FILE,
5352
scope=YOUTUBE_READ_WRITE_SCOPE,
5453
message=MISSING_CLIENT_SECRETS_MESSAGE)
@@ -57,7 +56,7 @@ def get_authenticated_service():
5756
credentials = storage.get()
5857

5958
if credentials is None or credentials.invalid:
60-
credentials = run(flow, storage)
59+
credentials = run_flow(flow, storage, args)
6160

6261
return build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION,
6362
http=credentials.authorize(httplib2.Http()))
@@ -73,16 +72,15 @@ def unset_watermark(youtube, channel_id):
7372

7473

7574
if __name__ == "__main__":
76-
parser = OptionParser()
77-
parser.add_option("--channelid", dest="channelid",
75+
argparser.add_argument("--channelid", dest="channelid",
7876
help="Required; id of channel whose watermark you're updating.")
79-
(options, args) = parser.parse_args()
80-
81-
if not options.channelid:
82-
parser.print_help()
77+
args = argparser.parse_args()
78+
79+
if not args.channelid:
80+
argparser.print_help()
8381
exit()
8482

85-
youtube = get_authenticated_service()
83+
youtube = get_authenticated_service(args)
8684

87-
unset_watermark(youtube, options.channelid)
85+
unset_watermark(youtube, args.channelid)
8886
print "The watermark was successfully unset."

0 commit comments

Comments
 (0)