- python3
$ pip3 install google-python-api-client
$ copy > config.json
{ "api_key" : "your api key" }
{ "channel" : "channel id" }
https://gist.github.com/eggman/b5feb8af46f1558146f0a50297b1c47e
$ pip3 install google-python-api-client
$ copy > config.json
{ "api_key" : "your api key" }
{ "channel" : "channel id" }
https://gist.github.com/eggman/b5feb8af46f1558146f0a50297b1c47e
| # -*- coding: utf-8 -*- | |
| import os | |
| import googleapiclient.discovery | |
| import googleapiclient.errors | |
| import json | |
| import pprint | |
| scopes = ["https://www.googleapis.com/auth/youtube.readonly"] | |
| def main(): | |
| api_service_name = "youtube" | |
| api_version = "v3" | |
| json_open = open('config.json', 'r') | |
| json_load = json.load(json_open) | |
| api_key = json_load['api_key'] | |
| ch = json_load['channel'] | |
| youtube = googleapiclient.discovery.build( | |
| api_service_name, api_version, developerKey=api_key) | |
| request = youtube.playlists().list( | |
| part="snippet,contentDetails", | |
| channelId=ch, | |
| maxResults=25 | |
| ) | |
| response = request.execute() | |
| pprint.pprint(response) | |
| if __name__ == "__main__": | |
| main() | |