Last active
February 28, 2016 13:46
-
-
Save yangsheng1107/dbcd26c31402d9c4dc72 to your computer and use it in GitHub Desktop.
透過 python 來看 youtube live streaming
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "Taiwan":[ | |
| {"name":"東森新聞","url":"https://www.youtube.com/watch?v=jMN4cxyhJjk"}, | |
| {"name":"中天新聞","url":"https://www.youtube.com/watch?v=hgIfZz8STLk"}, | |
| {"name":"民視新聞","url":"https://www.youtube.com/watch?v=XxJKnDLYZz4"}, | |
| {"name":"華視新聞","url":"https://www.youtube.com/watch?v=g9uJqP0hT_I"}, | |
| {"name":"公共電視","url":"https://www.youtube.com/watch?v=z9L9T2tetMQ"}, | |
| {"name":"UDN TV","url":"https://www.youtube.com/watch?v=SwrKzkRUlaw"}, | |
| {"name":"大愛一台","url":"https://www.youtube.com/watch?v=ESKjSwcswBM"}, | |
| {"name":"台視新聞","url":"https://www.youtube.com/watch?v=yk2CUjbyyQY"} | |
| ] | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import os | |
| import json | |
| from pprint import pprint | |
| with open('data.json') as data_file: | |
| data = json.load(data_file) | |
| for i in range(0, 8, +1): | |
| print (str(i) + " : " + data["Taiwan"][i]["name"]) | |
| ch = input("Your select? ") | |
| print (str(ch) + " : " + data["Taiwan"][ch]["name"]) | |
| cmd = "mpv " + data["Taiwan"][ch]["url"] + "youtube-dl --autofit=100%" | |
| os.system(cmd) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # mac 安裝方式 | |
| ```bash | |
| # brew install youtube-dl | |
| # brew cask install mpv | |
| ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment