#!/usr/bin/env python
# -*- coding: utf-8 -*-
from datetime import date
from httplib2 import Http
from oauth2client.service_account import ServiceAccountCredentials
from apiclient.discovery import build
# https://developers.google.com/api-client-library/python/start/get_started

json_file = 'secrets/YOUR_GOOGLE_PROJECT.json'
scopes = ['https://www.googleapis.com/auth/calendar.readonly']
credentials = ServiceAccountCredentials.from_json_keyfile_name(json_file, scopes=scopes)
http_auth = credentials.authorize(Http())
service = build("calendar", "v3", http=http_auth)

calendar_id = 'ja.japanese#holiday@group.v.calendar.google.com'

dtfrom = date(year=2016, month=1, day=1).isoformat() + "T00:00:00.000000Z"
dtto = date(year=2016, month=12, day=31).isoformat() + "T00:00:00.000000Z"

# ここのリクエストをいじってisHoliday(date) 的なメソッド作りたい
events_results = service.events().list(
        calendarId=calendar_id,
        timeMin=dtfrom,
        timeMax=dtto,
        maxResults=50,
        singleEvents=True,
        orderBy="startTime"
        ).execute()
events = events_results.get('items', [])
for event in events:
    print("%s\t%s" % (event["start"]["date"], event["summary"]))

fb9c22670600295b6573b386a4842619bb29168d
<mask token>

<mask token>
for event in events:
    print('%s\t%s' % (event['start']['date'], event['summary']))

<mask token>
json_file = 'secrets/YOUR_GOOGLE_PROJECT.json'
scopes = ['https://www.googleapis.com/auth/calendar.readonly']
credentials = ServiceAccountCredentials.from_json_keyfile_name(json_file,
    scopes=scopes)
http_auth = credentials.authorize(Http())
service = build('calendar', 'v3', http=http_auth)
calendar_id = 'ja.japanese#holiday@group.v.calendar.google.com'
dtfrom = date(year=2016, month=1, day=1).isoformat() + 'T00:00:00.000000Z'
dtto = date(year=2016, month=12, day=31).isoformat() + 'T00:00:00.000000Z'
events_results = service.events().list(calendarId=calendar_id, timeMin=
    dtfrom, timeMax=dtto, maxResults=50, singleEvents=True, orderBy='startTime'
    ).execute()
events = events_results.get('items', [])
for event in events:
    print('%s\t%s' % (event['start']['date'], event['summary']))

from datetime import date
from httplib2 import Http
from oauth2client.service_account import ServiceAccountCredentials
from apiclient.discovery import build
json_file = 'secrets/YOUR_GOOGLE_PROJECT.json'
scopes = ['https://www.googleapis.com/auth/calendar.readonly']
credentials = ServiceAccountCredentials.from_json_keyfile_name(json_file,
    scopes=scopes)
http_auth = credentials.authorize(Http())
service = build('calendar', 'v3', http=http_auth)
calendar_id = 'ja.japanese#holiday@group.v.calendar.google.com'
dtfrom = date(year=2016, month=1, day=1).isoformat() + 'T00:00:00.000000Z'
dtto = date(year=2016, month=12, day=31).isoformat() + 'T00:00:00.000000Z'
events_results = service.events().list(calendarId=calendar_id, timeMin=
    dtfrom, timeMax=dtto, maxResults=50, singleEvents=True, orderBy='startTime'
    ).execute()
events = events_results.get('items', [])
for event in events:
    print('%s\t%s' % (event['start']['date'], event['summary']))

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from datetime import date
from httplib2 import Http
from oauth2client.service_account import ServiceAccountCredentials
from apiclient.discovery import build
# https://developers.google.com/api-client-library/python/start/get_started

json_file = 'secrets/YOUR_GOOGLE_PROJECT.json'
scopes = ['https://www.googleapis.com/auth/calendar.readonly']
credentials = ServiceAccountCredentials.from_json_keyfile_name(json_file, scopes=scopes)
http_auth = credentials.authorize(Http())
service = build("calendar", "v3", http=http_auth)

calendar_id = 'ja.japanese#holiday@group.v.calendar.google.com'

dtfrom = date(year=2016, month=1, day=1).isoformat() + "T00:00:00.000000Z"
dtto = date(year=2016, month=12, day=31).isoformat() + "T00:00:00.000000Z"

# ここのリクエストをいじってisHoliday(date) 的なメソッド作りたい
events_results = service.events().list(
        calendarId=calendar_id,
        timeMin=dtfrom,
        timeMax=dtto,
        maxResults=50,
        singleEvents=True,
        orderBy="startTime"
        ).execute()
events = events_results.get('items', [])
for event in events:
    print("%s\t%s" % (event["start"]["date"], event["summary"]))
