youtube-pythonAPI自动发布

机器安装好pyhon3

1
2
3
4
5
wget --no-check-certificate  https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26
tar -zxvf setuptools-19.6.tar.gz
cd setuptools-19.6
python3 setup.py build
python3 setup.py install
1
2
3
4
5
6
wget "https://pypi.python.org/packages/source/p/pip/pip-7.1.0.tar.gz "
tar -zxvf pip-7.1.0.tar.gz\
cd pip-7.1.0
python3 setup.py build
python3 setup.py install
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
1
2
pip3 install --upgrade google-api-python-client oauth2client progressbar2
pip3 install httplib2==0.15.0
1
2
3
4
5
wget https://github.com/tokland/youtube-upload/archive/master.zip
unzip master.zip
cd youtube-upload-master
python3 setup.py install
ln -s /usr/local/python3/bin/youtube-upload /usr/bin/youtube-upload

将下载的OAuth的JSON文件重命名为:

1
/root/.client_secrets.json

上传视频,认证

1
youtube-upload --title="test_vedio" 455566.mp4

youtube-upload用法(可选参数):

1
2
3
4
5
6
7
8
9
10
11
--title="A.S. Mutter" " \
--description="A.S. Mutter plays Beethoven" \
--category="Music" \
--tags="mutter, beethoven" \
--recording-date="2011-03-10T15:32:17.0Z" \
--default-language="en" \
--default-audio-language="en" \
--client-secrets="my_client_secrets.json" \
--credentials-file="my_credentials.json" \
--playlist="My favorite music" \
--embeddable=True|False \

跳出这个,就用你的google帐号去访问URL进行认证,一般来说只需认证一次就行了。

youtube-1.png

报错1:

1
AttributeError: module `oauth2client` has no attribute `file`

解决方法:

1
2
3
vi /usr/local/python3/lib/python3.5/site-packages/youtube_upload/main.py
import oauth2client
from oauth2client import file #添加这行

报错2:

1
httplib2.RedirectMissingLocation: Redirected but the response is missing a Location: header.

解决方法:

1
pip3 install httplib2==0.15.0
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×