Skip to content

Instantly share code, notes, and snippets.

@zhongfly
zhongfly / set_proxy.lua
Last active February 3, 2024 07:03
Get windows system proxy(only support http proxy) and auto set proxy for mpv and ytdl_hook
local mp = require 'mp'
function string:trim()
return (self:gsub("^%s*(.-)%s*$", "%1"))
end
local function pwshexec(command)
local args = {
"powershell", "-NoProfile", "-Command"
}
@zhongfly
zhongfly / autosave.lua
Last active February 11, 2023 16:42
mpv script
-- autosave.lua
--
-- Instead of saving only on quit, 'watch later' data is saved periodically during playback and when a file is unloaded.
-- This lets you easily recover your position in the case of an ungraceful shutdown of mpv (crash, power failure, etc.).
--
-- You can configure the save period by editing the follow line.
--
-- local save_period = 60
--
-- This will set the save period to once every 60 seconds of playback, time while paused is not counted towards the save period timer.
@zhongfly
zhongfly / github-workflow-dispatch.js
Last active August 1, 2023 06:53
Pipedream Source/Action
//[Action] Github:Create a workflow dispatch event
import { Octokit } from "@octokit/core";
import { paginateRest } from "@octokit/plugin-paginate-rest";
import { default as github } from "@pipedream/github";
import { ConfigurationError } from "@pipedream/platform";
const CustomOctokit = Octokit.plugin(paginateRest);
export default defineComponent({
name: "Create a workflow dispatch event",
@zhongfly
zhongfly / updater.ps1
Last active November 18, 2023 02:54
Auto update libmpv
# https://github.com/shinchiro/mpv-packaging/blob/master/mpv-root/installer/updater.ps1
$fallback7z = Join-Path (Get-Location) "\7z\7zr.exe";
$useragent = "mpv-win-updater"
function Get-7z {
$7z_command = Get-Command -CommandType Application -ErrorAction Ignore 7z.exe
if ($7z_command) {
return $7z_command.Source
}
$7zdir = Get-ItemPropertyValue -ErrorAction Ignore "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" "InstallLocation"
@zhongfly
zhongfly / autosign.py
Created October 16, 2021 15:57
auto sign by click bot's button
# -*- encoding: utf-8 -*-
from telethon import TelegramClient
import re,time
api_id = 123456
api_hash = '123456'
toBot="@xxxxxx_bot"
client = TelegramClient('telethon', api_id, api_hash)
async def get_latest(entity):
message = await client.get_messages(entity,1)
@zhongfly
zhongfly / BiliIntlSubDownloader.py
Last active November 10, 2021 11:51
B站国际版简中字幕下载
# -*- encoding: utf-8 -*-
# python3.6
import json
import os
import requests
th_api = "https://api.biliintl.com"
BangumiInfoUrl = th_api + "/intl/gateway/web/view/ogv_collection"
@zhongfly
zhongfly / cidr-merger.py
Last active May 31, 2021 06:37
合并多个.txt或.rules文件中的所有ip cidr。usage: python3 cidr-merger.py [-h] [-o OUTFILE] filename [filename ...]
# -*- encoding: utf-8 -*-
from netaddr import *
import os
import argparse
# pyinstaller需要用以下方法获得exe所在位置
# workDir = os.path.dirname(os.path.realpath(sys.argv[0]))
workDir = os.getcwd()
def cidrReader(file):
with open(file,'r',encoding='utf-8') as f: