DeeCheung

DeeCheung

V2EX 第 13339 号会员,加入于 2011-11-05 09:34:57 +08:00
根据 DeeCheung 的设置,主题列表被隐藏
二手交易 相关的信息,包括已关闭的交易,不会被隐藏
DeeCheung 最近回复了
dufs
gdrive 是支持断点续传的,用 oauth2 client token 后可以导出到 aria2 里下载,6 小时过期后新 token 继续下就行,经常从团队盘里搬百 G 蓝光原盘的路过
我自己用 `Bun(自带 sqlite) + js` 解析提取,一个 Bun 二进制+脚本即可,你也可以打包在一起单文件当 cli 用,缺点不支持 win

``` js
// TODO v11 v12
import { Database } from 'bun:sqlite'
import { createDecipheriv, pbkdf2Sync } from 'node:crypto'

const KEY_LENGTH = 16
const SALT = 'saltysalt'
const IV = Buffer.alloc(KEY_LENGTH).fill(' ')
const password = 'peanuts'
const key = getDerivedKey(password, 1)

function getDerivedKey(password, iterations) {
return pbkdf2Sync(password, SALT, iterations, KEY_LENGTH, 'sha1')
}

function decryptorCookie(encryptedCookie) {
const decipher = createDecipheriv('AES-128-CBC', key, IV)
const decryptedCookie = decipher.update(encryptedCookie.slice(3))
return decryptedCookie.toString() + decipher.final('utf8')
}

function parseExpiresUtc(n) {
return new Date(n / 1e3 - 116444736e5)
}

function parseCookie(item) {
const { name, host_key, encrypted_value: str, expires_utc, has_expires } = item
// V10
const val = decryptorCookie(str)
const expires = parseExpiresUtc(expires_utc)
const unixTime = +(expires / 1e3).toFixed(0)
const out = { key: name, val, has_expires, expires, host: host_key, unixTime }
return out
}

const DefaultDbPath = '~/.config/chromium/Default/Cookies'
export function getCookies(sql, dbPath = DefaultDbPath) {
const db = new Database(dbPath)
const query = db.query(sql)
const items = query.all()
return items.map(parseCookie)
}

export function toNetscapeCookieFile(arr) {
const lines = arr
.map(c => {
return `${c.host} TRUE / TRUE ${c.unixTime} ${c.key} ${c.val}`
})
.join('\n')
return `# Netscape HTTP Cookie File
# This file is generated by yt-dlp. Do not edit.

${lines}`
}

export function toHeadersCookie(arr) {
return arr.map(c => `${c.key}=${c.val}`).join('; ')
}

if (import.meta.main) {
const sql = `SELECT * FROM cookies where host_key = '.aliyundrive.com' and name = 'cookie2';`
console.log(getCookies(sql))

const sql1 = `SELECT * FROM cookies where host_key = '.bilibili.com' and name = 'SESSDATA';`
const cookies = await getCookies(sql)
console.log(toNetscapeCookieFile(cookies))
}

```
239 天前
回复了 ppbaozi 创建的主题 宽带症候群 wireguard 偶现连不上,发送数据量疯长
我 linux 同上,前一段时间也出现过,也是同城电信,4G 回家,安卓没问题
251 天前
回复了 wy315700 创建的主题 V2EX 3000 天签到成就达成
手签 3605 ,中间断过很多次
328 天前
回复了 aqtata 创建的主题 程序员 有什么批量转换文件编码的工具推荐吗?
fd xargs conv
336 天前
回复了 MrGba2z 创建的主题 Android 问一个 ADB 和 usb hub 的问题
不插耳机呗,电脑播放,scrcpy 2.0 开始已经可以播放声音了
350 天前
回复了 coreki 创建的主题 程序员 作为程序猿居然投域名,亏到姥姥家了
2022-10-17 07:59:54 +08:00
回复了 mokevip 创建的主题 随想 突然发现,其实与其说喜欢折腾,不如说多巴胺成瘾
这时候可以弄 TG 群了,一起继续折腾边分享,边交流边找新坑,手动狗头
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2688 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 11ms · UTC 15:47 · PVG 23:47 · LAX 08:47 · JFK 11:47
Developed with CodeLauncher
♥ Do have faith in what you're doing.