Initial commit

This commit is contained in:
ForgQi committed 2018-01-07 19:54:48 +08:00
commit ae570bfad5
7 files changed
+337

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6.3 (C:\Users\44697\AppData\Local\Programs\Python\Python36\python.exe)" project-jdk-type="Python SDK" />
</project>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/bilibiliupload.iml" filepath="$PROJECT_DIR$/.idea/bilibiliupload.iml" />
</modules>
</component>
</project>
+160
View File
@@ -0,0 +1,160 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="58acc6c6-8ea5-48bb-95b2-31fcec9a4358" name="Default" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="upload.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/upload.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="207">
<caret line="9" column="32" lean-forward="true" selection-start-line="9" selection-start-column="32" selection-end-line="9" selection-end-column="32" />
<folding>
<element signature="e#0#30#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/upload.py" />
</list>
</option>
</component>
<component name="ProjectFrameBounds">
<option name="x" value="420" />
<option name="y" value="59" />
<option name="width" value="1352" />
<option name="height" value="895" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
<manualOrder />
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="bilibiliupload" type="b2602c69:ProjectViewProjectNode" />
<item name="bilibiliupload" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scratches" />
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager" selected="Python.upload">
<configuration name="upload" type="PythonConfigurationType" factoryName="Python">
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<module name="bilibiliupload" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/upload.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
</configuration>
</component>
<component name="ShelveChangesManager" show_recycled="false">
<option name="remove_strategy" value="false" />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="58acc6c6-8ea5-48bb-95b2-31fcec9a4358" name="Default" comment="" />
<created>1515325642492</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1515325642492</updated>
</task>
<servers />
</component>
<component name="ToolWindowManager">
<frame x="420" y="59" width="1352" height="895" extended-state="0" />
<layout>
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.24960877" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32968536" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
<window_info id="Data View" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/upload.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="207">
<caret line="9" column="32" lean-forward="true" selection-start-line="9" selection-start-column="32" selection-end-line="9" selection-end-column="32" />
<folding>
<element signature="e#0#30#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>
+1
View File
@@ -0,0 +1 @@
# bilibiliupload
+151
View File
@@ -0,0 +1,151 @@
from selenium import webdriver
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
service_log_path = "{}/chromedriver.log".format('/home')
video_path = '/home/wardiii.mp4'
options = webdriver.ChromeOptions()
options.add_argument('headless')
# options.add_argument('no-sandbox')
# options.binary_location = '/usr/bin/google-chrome-stable'
driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver',chrome_options=options,service_log_path=service_log_path)
driver.get("https://www.bilibili.com")
# cookie = {
# 'fts':'1511094141',
# 'buvid3':'0E299359-8055-4E58-9E82-DDF2F325CCAF26543infoc',
# 'UM_distinctid':'15fdc423182b22-07a38f91352cb7-7b113d-144000-15fdc423183a13',
# 'pgv_pvi':'3700880384',
# 'rpdid':'olklsxmolldosooiiqlpw',
# 'sid':'8k9huzd0',
# 'finger':'edc6ecda',
# 'DedeUserID':'274986200',
# 'DedeUserID__ckMd5':'1206e39bc044fe98',
# 'SESSDATA':'3e02f3d0%2C1517749345%2C489ac7f7',
# 'bili_jct':'4a71e9d389551c4bb7a9ebd05ac7dda0',
# 'member_v2':'1',
# 'pgv_si':'s2364394496',
# '_dfcaptcha':'8c4345e68b07f547aa3f246b7b058cd1',
# 'LIVE_BUVID':'a23404d890e536c9a93b72e5e50be145',
# 'LIVE_BUVID__ckMd5':'d5ea746722041186'
# }
# 964b42c0
# bahkjm41
# 1515221245
# EB49C459-95CA-415C-AA48-B3FE5B46BD9D31043infoc
# 3e02f3d0%2C1517813257%2C06f75553
# 1ef343ac61192cd3aa59ca9aea289ff3
# c25a35691b8ef1fc2f2566a1c4df50b4
# AUTO1115152212636167
# 814ce92affe021564ee8f5ceca806c4a
cookies = [{'name': 'finger', 'value': 'edc6ecda', 'path': '/', 'domain': '.bilibili.com', 'expiry': None, 'secure': False, 'httpOnly': False},
{'name': 'sid', 'value': '8k9huzd0', 'path': '/', 'domain': '.bilibili.com', 'expiry': None, 'secure': False, 'httpOnly': False},
{'name': 'fts', 'value': '1511094141', 'path': '/', 'domain': '.bilibili.com', 'expiry': None, 'secure': False, 'httpOnly': False},
{'name': 'buvid3', 'value': '0E299359-8055-4E58-9E82-DDF2F325CCAF26543infoc', 'path': '/', 'domain': '.bilibili.com', 'expiry': None, 'secure': False, 'httpOnly': False},
{'name': 'DedeUserID', 'value': '274986200', 'path': '/', 'domain': '.bilibili.com', 'expiry': None, 'secure': False, 'httpOnly': False},
{'name': 'DedeUserID__ckMd5', 'value': '1206e39bc044fe98', 'path': '/', 'domain': '.bilibili.com', 'expiry': None, 'secure': False, 'httpOnly': False},
{'name': 'SESSDATA', 'value': '3e02f3d0%2C1517749345%2C489ac7f7', 'path': '/', 'domain': '.bilibili.com', 'expiry': None, 'secure': False, 'httpOnly': True},
{'name': 'bili_jct', 'value': '4a71e9d389551c4bb7a9ebd05ac7dda0', 'path': '/', 'domain': '.bilibili.com', 'expiry': None, 'secure': False, 'httpOnly': False},
{'name': '_dfcaptcha', 'value': '8c4345e68b07f547aa3f246b7b058cd1', 'path': '/', 'domain': '.bilibili.com', 'expiry': None, 'secure': False, 'httpOnly': True},
{'name': 'LIVE_BUVID', 'value': 'a23404d890e536c9a93b72e5e50be145', 'path': '/', 'domain': '.bilibili.com', 'expiry': None, 'secure': False, 'httpOnly': False}]
# driver.delete_all_cookies()
for cookie in cookies:
# cookie.pop('domain')
# print(cookie)
driver.add_cookie(cookie)
# driver.add_cookie({'name': 'finger', 'value': 'edc6ecda'})
# driver.add_cookie({'name': 'fts', 'value': '1511094141'})
# driver.add_cookie({'name': 'buvid3', 'value': '0E299359-8055-4E58-9E82-DDF2F325CCAF26543infoc'})
# # driver.add_cookie({'name': 'UM_distinctid', 'value': '15fdc423182b22-07a38f91352cb7-7b113d-144000-15fdc423183a13'})
# # driver.add_cookie({'name': 'pgv_pvi', 'value': '3700880384'})
# # driver.add_cookie({'name': 'rpdid', 'value': 'olklsxmolldosooiiqlpw'})
# driver.add_cookie({'name': 'sid', 'value': '8k9huzd0'})
# driver.add_cookie({'name': 'DedeUserID', 'value': '274986200'})
# driver.add_cookie({'name': 'DedeUserID__ckMd5', 'value': '1206e39bc044fe98'})
# driver.add_cookie({'name': 'SESSDATA', 'value': '3e02f3d0%2C1517749345%2C489ac7f7'})
# driver.add_cookie({'name': 'bili_jct', 'value': '814ce92affe021564ee8f5ceca806c4a'})
# # driver.add_cookie({'name': 'member_v2', 'value': '1'})
# # driver.add_cookie({'name': 'pgv_si', 'value': 's2364394496'})
# driver.add_cookie({'name': '_dfcaptcha', 'value': '8c4345e68b07f547aa3f246b7b058cd1'})
# driver.add_cookie({'name': 'LIVE_BUVID', 'value': 'a23404d890e536c9a93b72e5e50be145'})
# # driver.add_cookie({'name': 'LIVE_BUVID__ckMd5', 'value': 'd5ea746722041186'})
# cookie = driver.get_cookies()
# print(cookie)
# driver.get("https://www.bilibili.com")
driver.get("https://member.bilibili.com/video/upload.html")
# driver.add_cookie(cookie)
# time.sleep(20)
# cookie = driver.get_cookies()
# print(cookie)
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.NAME, 'file')))
upload = driver.find_element_by_name('file')
# time.sleep(5)
print(driver.title)
upload.send_keys(video_path) # send_keys
# print(upload.get_attribute('value')) # check value
while 1:
info = driver.find_element_by_xpath('//*[@id="sortWrp"]/li/div[2]/div[1]/div[3]')
print(info.text)
time.sleep(20)
text = driver.find_element_by_class_name('upload-status').text
print(text)
if text == 'Upload complete':
break
# print(text)
# pageSource = driver.page_source
# print(pageSource)
# hid = driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div[2]/div[2]/div[2]/div[1]/div[1]/div/div[1]/label[1]/div')
# driver.execute_script('arguments[0].style.display="none";',hid)
# hid_1 = driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div[2]/div[2]/div[2]/div[1]/div[1]/div/div[1]/label[1]')
# driver.execute_script('arguments[0].style.display="none";',hid_1)
#
# time.sleep(1)
click = driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div[2]/div[2]/div[2]/div[1]/div[1]/div/div[1]/label[1]/div')
# click = driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div[2]/div[2]/div[1]/div[1]/div[2]/div[1]')
# click = driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div[2]/div[2]/div[2]/div[1]/div[1]/div/div[1]/label[2]/input')
# click = driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div[2]/div[2]/div[2]/div[1]/div[1]/div/div[1]/label[1]/input')
# click.send_keys(Keys.ENTER)
click.click()
# driver.execute_script('arguments[0].className = "is-checked";',click)
# print(click.is_selected())
# print(clicks)
# for click in clicks:
# click_1.click()
# driver.find_elements_by_class_name('is-checked')[1].click()
# click_1 = driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div[2]/div[2]/div[2]/div[1]/div[1]/div/div[3]/div[1]/div[2]/label/input')
click_1 = driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div[2]/div[2]/div[2]/div[1]/div[1]/div/div[3]/div[1]/div[2]/label/div')
click_1.click()
# 点击游戏
driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div[2]/div[2]/div[2]/div[1]/div[2]/div[1]/ul/li[3]/button').click()
# 点击电子竞技
driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div[2]/div[2]/div[2]/div[1]/div[2]/div[1]/ul/li[3]/ul/li[6]').click()
text = driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div[2]/div[2]/div[2]/div[1]/div[4]/div[2]/div[2]/div[2]/div/div/input')
text.send_keys('星际2')
text.send_keys(Keys.ENTER)
time.sleep(0.5)
text.send_keys('第一视角')
text.send_keys(Keys.ENTER)
time.sleep(0.5)
text.send_keys('职业选手')
text.send_keys(Keys.ENTER)
time.sleep(0.5)
text.send_keys('虚空之遗')
text.send_keys(Keys.ENTER)
time.sleep(0.5)
# 输入相关游戏
text_1 = driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div[2]/div[2]/div[2]/div[1]/div[5]/div[1]/div[1]/div[1]/div/input')
text_1.send_keys('星际争霸2')
# 简介
text_2 = driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div[2]/div[2]/div[2]/div[1]/div[5]/div[1]/div[2]/div[1]/div/textarea')
text_2.send_keys('职业选手直播第一视角录像。')
driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div/div[2]/div[2]/div[2]/div[3]/button').click()
print('稿件提交完成!')
driver.quit()