def login(self):
     b = Bilibili()
     b.login(username=self.username, password=self.password)
     self.access_token = b.access_token
     self.sessdata = b._session.cookies['SESSDATA']
     self.bili_jct = b._session.cookies['bili_jct']
     print(f"login successfully! {self.name} {self.access_token} {self.sessdata} {self.bili_jct}")
     self.verify = Verify(sessdata=self.sessdata, csrf=self.bili_jct)
예제 #2
0
def gen_process() -> list:
    event_list = []
    if config['youtube']['enable']:
        for user_config in config['youtube']['users']:
            y = Youtube(user_config)
            event_list.append(y)
    if config['twitcasting']['enable']:
        for user_config in config['twitcasting']['users']:
            t = Twitcasting(user_config)
            event_list.append(t)
    if config['openrec']['enable']:
        for user_config in config['openrec']['users']:
            o = Openrec(user_config)
            event_list.append(o)
    if config['mirrativ']['enable']:
        for user_config in config['mirrativ']['users']:
            m = Mirrativ(user_config)
            event_list.append(m)
    if config['bilibili']['enable']:
        for user_config in config['bilibili']['users']:
            b = Bilibili(user_config)
            event_list.append(b)
            if user_config['article']:
                b1 = BilibiliArticle(user_config)
                event_list.append(b1)
            if user_config['live']:
                b2 = BilibiliLive(user_config)
                event_list.append(b2)
    return event_list
예제 #3
0
 def play(self, url, title=""):
     self.init_danmaku(url)
     url = Bilibili.get_live_address(url, index=2)
     print(url)
     self.mpv.command("loadfile", url)
     self.video_window.show()
     self.video_window.setWindowTitle(title)
예제 #4
0
async def main():
    if "youtube.com/channel" in sys.argv[1] or "youtube.com/watch" in sys.argv[
            1]:
        s = Youtube(sys.argv[1], sys.argv[2] if len(sys.argv) > 2 else "")
        data = await s.get_play_info()
        title = data["title"]
        url = data["play_url"]
    elif "twitch.tv/" in sys.argv[1]:
        s = Twitch(sys.argv[1], sys.argv[2] if len(sys.argv) > 2 else "")
        data = await s.get_play_info()
        title = data["title"]
        url = data["play_url"]
    elif "douyu.com/" in sys.argv[1]:
        s = Douyu(sys.argv[1], sys.argv[2] if len(sys.argv) > 2 else "")
        data = await s.get_play_info()
        title = data["title"]
        url = data["play_url"]
    elif "huya.com/" in sys.argv[1]:
        s = Huya(sys.argv[1], sys.argv[2] if len(sys.argv) > 2 else "")
        data = await s.get_play_info()
        title = data["title"]
        url = data["play_url"]
    elif "live.bilibili.com/" in sys.argv[1]:
        s = Bilibili(sys.argv[1], sys.argv[2] if len(sys.argv) > 2 else "")
        data = await s.get_play_info()
        title = data["title"]
        url = data["play_url"]
    elif "bilibili.com/" in sys.argv[1]:
        s = Bilibili(sys.argv[1], sys.argv[2] if len(sys.argv) > 2 else "")
        await s.get_play_info_video()
        return
    else:
        await run_ykdl(sys.argv[1])
        return

    print("title: " + title, flush=True)
    print(url, flush=True)
예제 #5
0
def get_bilibili_parser(url):
    """获取downloader对象
    如果已经缓存了,就直接读取。(开发阶段用缓存的话,就不会一不小心被封ip了)
    否则就新建"""

    dump_name = url.rsplit('/')[-1] + '.pickle'
    dump_path = './pickles/' + dump_name

    if has_file('./pickles', dump_name):
        bilibili_parser = load(dump_path)
    else:
        bilibili_parser = Bilibili(url)
        dump(bilibili_parser, dump_path)

    return bilibili_parser
예제 #6
0
def login_handle(args):
    bilibili = Bilibili()
    if bilibili.login(username=args.username, password=args.password):
        bilibili.get_user_info()
        with open(os.path.join(bundle_dir, "cookies.json"),
                  "w",
                  encoding="utf-8") as f:
            f.write(
                json.dumps(bilibili.get_cookies(),
                           ensure_ascii=False,
                           indent=2))
예제 #7
0
 def gen_process(self):
     if config['youtube']['enable']:
         for user_config in config['youtube']['users']:
             y = Youtube(user_config)
             self.events_multi.append(y)
     if config['twitcasting']['enable']:
         for user_config in config['twitcasting']['users']:
             t = Twitcasting(user_config)
             self.events_multi.append(t)
     if config['openrec']['enable']:
         for user_config in config['openrec']['users']:
             o = Openrec(user_config)
             self.events_multi.append(o)
     if config['mirrativ']['enable']:
         for user_config in config['mirrativ']['users']:
             m = Mirrativ(user_config)
             self.events_multi.append(m)
     if config['bilibili']['enable']:
         for user_config in config['bilibili']['users']:
             b = Bilibili(user_config)
             self.events_multi.append(b)
예제 #8
0
 def start_bilibili():
     for b_id in bilibili_id:
         b = Bilibili()
         b.actor(b_id)
예제 #9
0
def log(message):
    Bilibili._log(message)
예제 #10
0
    raise
accounts = []
for line in config['user']['account'].splitlines():
    try:
        if line[0] == "#":
            continue
        pairs = {}
        for pair in line.strip(";").split(";"):
            if len(pair.split("=")) == 2:
                key, value = pair.split("=")
                pairs[key] = value
        password = all(key in pairs for key in ["username", "password"])
        token = all(key in pairs for key in ["access_token", "refresh_token"])
        cookie = all(
            key in pairs for key in
            ["bili_jct", "DedeUserID", "DedeUserID__ckMd5", "sid", "SESSDATA"])
        if password or token or cookie:
            accounts.append(pairs)
    except:
        pass

config['user'].pop("account")

instance = Bilibili(config['global']['https'], Queue())
instance.login(force_refresh_token=False, **accounts[0])

sys.stdout = oristdout
print(
    requests.cookies.get_cookie_header(
        instance._session.cookies,
        requests.Request('GET', 'https://www.bilibili.com')))
예제 #11
0
from bilibili import Bilibili
# 读取配置文件
config = configparser.ConfigParser()
config.read("config.ini", encoding="utf-8")
COOKIES_TXT_PATH = config.get('basic', 'COOKIES_TXT_PATH')
BILIBILI_ROOM_TITLE = config.get('live', 'BILIBILI_ROOM_TITLE')
FFMPEG_COMMAND = config.get('live', 'FFMPEG_COMMAND')
YOUTUBE_LIVE_URL = config.get('youtube-dl', 'YOUTUBE_LIVE_URL')
ALWAYS_USE_HIGHEST_QUALITY = config.getboolean('youtube-dl',
                                               'ALWAYS_USE_HIGHEST_QUALITY')
BILIBILI_ROOM_AREA_ID = config.getint('live', 'BILIBILI_ROOM_AREA_ID')

if __name__ == '__main__':
    LOGIN_STATUS = False
    print("[提示]Youtube转播工具v1.0")
    b = Bilibili()
    if os.path.exists(COOKIES_TXT_PATH):  # 自动登录
        print("[提示]找到cookies.txt,尝试自动登录...")
        b.login_by_cookies(COOKIES_TXT_PATH)
        if b.isLogin():
            LOGIN_STATUS = True
    if not LOGIN_STATUS:
        cookies = input("[提示]请粘贴cookies信息:")
        b.login_by_cookies_str(cookies)
        b.isLogin()
    my_info = b.get_my_basic_info()
    print("[提示][已登录账号{}][mid:{}][昵称:{}]".format(my_info['userid'],
                                                my_info['mid'],
                                                my_info['uname']))

    youtube_live_url = YOUTUBE_LIVE_URL
예제 #12
0
    "i_s": 2048000,
    "max": 75,
    "dow": "echo 'clean'",
    # 仅下载
    "dlO": True,
    # 下播延迟投稿
    "dly": 30,
    # 短的时间的格式
    "sdf": "%Y%m%d",
    "enc": "ffmpeg -i {f} -c:v copy -c:a copy -f mp4 {t} -y"
}
doCleanTime = datetime.fromtimestamp(0)
loginTime = datetime.fromtimestamp(0)
_clean_flag = None
delay = datetime.fromtimestamp(0)
b = Bilibili()

network = [{
    "currentTime": datetime.now(),
    "out": {
        "currentByte": psutil.net_io_counters().bytes_sent,
    },
    "in": {
        "currentByte": psutil.net_io_counters().bytes_recv,
    }
}, {
    "currentTime": datetime.now(),
    "out": {
        "currentByte": psutil.net_io_counters().bytes_sent,
    },
    "in": {