跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[分享创造] 小白依靠 GPT4 生成 PowerShell 按文件名筛选出国语影视种子

发表于

最近常用的公共影视资源网站关闭,迁移到一个新网站,结果丢失了很多资源。我偶然发现有人发了十几个名为“老种子 xx”的帖子,上传了几十个 20 MiB 的 .rar 压缩文件(由于附件大小限制)。我一个个下载下来,虽然是老种子,但用网盘离线下载还是可行的。现在的问题是,我想找出国语音频的作品,该怎么筛选出国语音轨的种子列表。针对这个问题,我问了免费的 GPT4 。它直接帮我写 PowerShell 脚本:

# 获取当前目录下的所有 .rar 文件
$rarFiles = Get-ChildItem -Path . -Filter *.rar

# 存储符合条件的 .torrent 文件的信息
$matchingTorrents = @()

# 正则表达式模式
$pattern = "Mandarin|CHS|CHINESE"

# 遍历所有 .rar 文件
foreach ($rarFile in $rarFiles) {
    # 解压 .rar 文件并列出其内容
    $contents = & 7z l $rarFile.FullName
    
    # 从内容中查找 .torrent 文件
    $torrentFiles = $contents | Where-Object { $_ -match ".torrent" }
    
    # 查找文件名符合模式的 .torrent 文件
    foreach ($line in $torrentFiles) {
        if ($line -match $pattern) {
            # 直接使用文件路径信息(原先 GPT4 给的-replace ".*(\d{2}-\d{2}).* ", "")
            $filePath = $line

            # 创建一个对象存储 .rar 文件名和 .torrent 文件路径
            $torrentInfo = [PSCustomObject]@{
                RarFile = $rarFile.FullName
                TorrentFile = $filePath
            }

            # 将对象添加到匹配列表中
            $matchingTorrents += $torrentInfo
        }
    }
}

# 输出匹配的 .torrent 文件信息
$matchingTorrents | Format-Table -AutoSize

运行脚本

将上述脚本保存为一个 PowerShell 文件,例如search_torrents_with_paths.ps1,然后在 PowerShell 中执行脚本:

.\search_torrents_with_paths.ps1

(我的台式机 Windows10 默认禁止运行脚本,我是在交互式 PowerShell 直接粘贴代码运行的)

后续列表有很多重复数据,为了去重,将文件改名为 .csv 文件并导入 Excel 。我用的是微软在线的免费 Excel ,通过数据功能进行文本拆分、筛选与去重。文件名包含年份,比如 2008 ,可以提取年份数字筛选出 2000 年以后的作品。

关于怎么筛选出豆瓣评分 8 分以上的种子文件,我问过 GPT4 ,通过 Python 的 requests 和使用豆瓣的官方 API 获取数据。因为 GPT4 警告这样做有被封 IP 的风险,我就直接放弃了,只好人工查评分。

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.