-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·97 lines (88 loc) · 2.86 KB
/
main.py
File metadata and controls
executable file
·97 lines (88 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env python
# -*- coding: UTF-8 -*-.
import os
import coloredlogs, logging, logging.config
from acfun_uploader_cli.config import get_userinfo
from acfun_uploader_cli.channel import *
from acfun_uploader_cli.uploader import Acfun
# Refer to
# 1. https://stackoverflow.com/a/7507842/1677041
# 2. https://stackoverflow.com/a/49400680/1677041
# 3. https://docs.python.org/2/library/logging.config.html
LOGGING_CONFIG = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'standard': {
'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
},
'colored': {
'()': 'coloredlogs.ColoredFormatter',
'format': "%(asctime)s - %(name)s - %(levelname)s - %(message)s",
'datefmt': '%H:%M:%S',
}
},
'handlers': {
'default': {
'level': 'DEBUG' if __debug__ else 'INFO',
'formatter': 'standard',
'class': 'logging.StreamHandler',
'stream': 'ext://sys.stdout', # Default is stderr
},
'console': {
'level': 'DEBUG' if __debug__ else 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'colored',
'stream': 'ext://sys.stdout'
},
'file': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'standard',
'filename': 'main.log',
'maxBytes': 1024 * 1024,
'backupCount': 10
},
},
'loggers': {
'': { # root logger
'handlers': ['console', 'file'],
'level': 'DEBUG',
'propagate': False
},
'__main__': { # if __name__ == '__main__'
'handlers': ['console', 'file'],
'level': 'DEBUG',
'propagate': False
},
'acfun_uploader_cli': {
'handlers': ['console', 'file'],
'level': 'DEBUG',
'propagate': False
},
}
}
logging.config.dictConfig(LOGGING_CONFIG)
logger = logging.getLogger(__name__)
def main():
logger.info('Debug is %s', 'on' if __debug__ else 'off')
username, password = get_userinfo()
if len(username) <= 0 or len(password) <= 0:
logger.warning('Invalid user info for login.')
return
project_dir = os.path.dirname(os.path.abspath(__file__))
acer = Acfun(username, password, headless=False)
acer.check_login() or acer.login()
acer.upload_video(
title='acfun video poster',
cover=os.path.join(project_dir, 'sample-data', 'cover.png'),
channel=u'生活',
sub_channel=u'生活日常',
tags=['a', 'b'],
descriptions='balabala...',
video=os.path.join(project_dir, 'sample-data', 'main.mp4')
)
if __name__ == '__main__':
main()
# fetch_channel_info(True)
# choose_channel()