bilidirectuploader V0.1:测试性的B站自家直传命令行上传工具
一部分照搬了acupload的代码,但是也重写了很多地方。不代表acupload就不能用了。。。 不用requests真不行。 前面按理说应该都用requests重写,懒了。 https://github.com/cnbeining/bilidirectuploader 代码扔下面。
一部分照搬了acupload的代码,但是也重写了很多地方。不代表acupload就不能用了。。。 不用requests真不行。 前面按理说应该都用requests重写,懒了。 https://github.com/cnbeining/bilidirectuploader 代码扔下面。
没有测试,请大家测试后反馈是否正常。 应该是没啥问题的。 需要requests,没这货干活太不方便了。
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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
#!/usr/bin/env python3 #coding:utf-8 # Author: Beining --<ACICFG> # Purpose: Upload to Bilibili via Bilibili's internal uploading method # Created: 10/01/2014 #python3 bilidirectuploader.py 0.flv 1.flv import urllib.request import sys import os import json import subprocess import hashlib import requests global cookiepath cookiepath = './bilicookies' global video_list video_list = '' #---------------------------------------------------------------------- def upload(file2Upload): """""" #Read Cookie.....Damn it I didn't have my supper! try: cookies = open(cookiepath, 'r').readline() #print(cookies) except: print('I am hungry, please give me your Cookie!') exit() #Get filename if not os.path.isfile(file2Upload): print('Not file!') pass if os.path.splitext(file2Upload)[1] != '.flv': print('ERROR: You can only upload .flv file(s)!') exit() filename = os.path.basename(file2Upload) #print(filename) #Calculate Filesize, since there s 1.4GiB limit filesize = os.path.getsize(file2Upload) print('Size of file: ' + str(filesize)) if filesize > (1.4 * 1024 * 1024 * 1024): print('File larger than 1.4 GiB, unable to upload!') exit() #Fetch UploadUrl request_full = urllib.request.Request('http://member.bilibili.com/get_vupload_url', headers={ 'User-Agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36', 'Cache-Control': 'no-cache', 'Pragma': 'no-cache' , 'Cookie': cookies,}) try: response = urllib.request.urlopen(request_full) except Exception: print('Cannot get response from server!') pass data = response.read() uploadresponse = json.loads(data.decode('utf-8')) try: # if error happens... uploadresponse["error_code"] except KeyError: pass except: print('ERROR: '+ uploadresponse['error_msg'] + ', ' + str(uploadresponse["error_code"])) sys.exit() # exit the program #print(uploadresponse['url']) #make filename server_ip = str(uploadresponse['server_ip']) remote_file_name = str(uploadresponse['file_name']) #start upload upload_url = str(uploadresponse['url']) #print(upload_url) f = open(file2Upload, 'rb') c = 0 for piece in read_in_chunks(f): c = c + 1 requests.options(upload_url) #dont really know why files = {'file': piece} r = requests.post(upload_url, files=files) print(str(c * 524288) + '/' + str(filesize) + ' done...') video_list = video_list + (str('[vupload]' + remote_file_name + ';' + filename + ';' + server_ip + ';[/vupload]\n')) print('\n'+'Hope everything is fine. '+ '\n' + '[vupload]' + remote_file_name + ';' + filename + ';' + server_ip + ';[/vupload]') #---------------------------------------------------------------------- def read_in_chunks(file_object, chunk_size=524288): """Lazy function (generator) to read a file piece by piece. Default chunk size: 524288.""" while True: data = file_object.read(chunk_size) if not data: break yield data #---------------------------------------------------------------------- if __name__=='__main__': #Test sys encoding if not sys.getdefaultencoding() is 'utf-8': os.system('export LC_ALL="en_US.UTF-8"') total_file_num = len(sys.argv[1:]) i = 0 if len(sys.argv[1:]) == 0: print(''' Author: Beining http://www.cnbeining.com https://github.com/cnbeining Require: requests Usage: python3 bilidirectuploader.py [file1] [file2] [file3]... You can only upload .flv file(s) under 1.4 GiB. If network is bad, change chunk size at L85, and display at L78. ''') for name in sys.argv[1:]: #print(name) i = i + 1 print('Uploading '+ str(i)+' in '+str(total_file_num)+' files...') upload(name) if len(video_list) != 0: print(video_list) |
SB的机器出了问题: I do apologize. We’ve resolved the issue with your container. It does appear that one of our administrators incorrectly typed an IP on another device in the same… Read more »
更新: 我的中文翻译已经merge了,大家可以看中文了。 Beining 之前一直没有推荐Mailvelope。因为这货不能签名,所以一直使用GPGTools。 但是这东西必须和系统整合,所以携带不便。当然有个优点是可以一并加密文件。 现在Mailvelope支持了签名,而且进行了安全审计。所以开始推荐这个东西。 对于不方便使用软件的地方,Mailvelope是极其好用的工具。 以下都以Chrome举例,FF类似。 国产浏览器,安全软件绝对不推荐。 初级篇: 1.安装: https://www.mailvelope.com/ 去Chrome网上商店可以安装。 2.初次使用,设置密钥: 点Options。 如果你没有密钥: 创建密钥: 稍候就好了。 如果你已经有了密钥: 2. 加密邮件 0…. Read more »
https://github.com/ACICFG/youBBS-ACICFG/tree/Beining-add-save-pic 反反盗链会弄得页面里面全是frame,整死强迫症系列。 之前有过imgur封号和封网站的先例,所以我在这里扔上。 这个应该是唯一一个可以不通过服务器转发的反反盗链办法。 Javascript写起来太痛苦了。 利用了HTML5的特性,一开始加载图片的高度会不对。之后应该会自己修正。 强制imgur走https,这样应该不会撞墙。 自取。