From c7792745bfd6191e5673b70c604651539a598480 Mon Sep 17 00:00:00 2001 From: limil Date: Thu, 8 May 2025 22:51:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E4=B8=BApython?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 135 --------------------------- BangumiRenamer.sln | 16 ---- BangumiRenamer/BangumiRenamer.csproj | 14 --- BangumiRenamer/Program.cs | 31 ------ BangumiRenamer/TMDbHelper.cs | 26 ------ Prompt.txt | 98 +++++++++++++++++++ ds.py | 16 ++++ main.py | 20 ++++ 8 files changed, 134 insertions(+), 222 deletions(-) delete mode 100644 .gitignore delete mode 100644 BangumiRenamer.sln delete mode 100644 BangumiRenamer/BangumiRenamer.csproj delete mode 100644 BangumiRenamer/Program.cs delete mode 100644 BangumiRenamer/TMDbHelper.cs create mode 100644 Prompt.txt create mode 100644 ds.py create mode 100644 main.py diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 5f06570..0000000 --- a/.gitignore +++ /dev/null @@ -1,135 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results - -[Dd]ebug/ -[Rr]elease/ -x64/ -[Bb]in/ -[Oo]bj/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.log -*.svclog -*.scc - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# Click-Once directory -publish/ - -# Publish Web Output -*.Publish.xml -*.pubxml -*.azurePubxml - -# NuGet Packages Directory -## TODO: If you have NuGet Package Restore enabled, uncomment the next line -packages/ -## TODO: If the tool you use requires repositories.config, also uncomment the next line -!packages/repositories.config - -# Windows Azure Build Output -csx/ -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -sql/ -*.Cache -ClientBin/ -[Ss]tyle[Cc]op.* -![Ss]tyle[Cc]op.targets -~$* -*~ -*.dbmdl -*.[Pp]ublish.xml - -*.publishsettings - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -App_Data/*.mdf -App_Data/*.ldf - -# ========================= -# Windows detritus -# ========================= - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Mac desktop service store files -.DS_Store - -_NCrunch* - -.idea \ No newline at end of file diff --git a/BangumiRenamer.sln b/BangumiRenamer.sln deleted file mode 100644 index 431aa04..0000000 --- a/BangumiRenamer.sln +++ /dev/null @@ -1,16 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BangumiRenamer", "BangumiRenamer\BangumiRenamer.csproj", "{46889D6D-165B-4984-A4A6-D2589EE3BE27}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {46889D6D-165B-4984-A4A6-D2589EE3BE27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {46889D6D-165B-4984-A4A6-D2589EE3BE27}.Debug|Any CPU.Build.0 = Debug|Any CPU - {46889D6D-165B-4984-A4A6-D2589EE3BE27}.Release|Any CPU.ActiveCfg = Release|Any CPU - {46889D6D-165B-4984-A4A6-D2589EE3BE27}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection -EndGlobal diff --git a/BangumiRenamer/BangumiRenamer.csproj b/BangumiRenamer/BangumiRenamer.csproj deleted file mode 100644 index dc36739..0000000 --- a/BangumiRenamer/BangumiRenamer.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - - - - - diff --git a/BangumiRenamer/Program.cs b/BangumiRenamer/Program.cs deleted file mode 100644 index 15eb4ae..0000000 --- a/BangumiRenamer/Program.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Text; -using System.Text.Json; - -// var basePath = "\\\\192.168.31.10\\media\\downloads\\aria2\\"; -// -// -// -// -// -// var files = Directory.GetFiles(basePath, "*.*", SearchOption.AllDirectories); -// -// files = files.Select(file => file.Replace(basePath, "").Replace("\\", "/")).ToArray(); -// -// StringBuilder result = new StringBuilder(); -// -// foreach (var file in files) -// { -// result.AppendLine(file); -// } -// -// File.WriteAllText("files.txt", result.ToString()); -// -// - -var filePath = "Lie.To.Me.S02.1080p.WEBRip.x265-RARBG/Lie.To.Me.S02E20.1080p.WEBRip.x265-RARBG.mp4"; - -var dirPart = Path.GetDirectoryName(filePath); -var namePart = Path.GetFileNameWithoutExtension(filePath); -var extension = Path.GetExtension(filePath); - -Console.Write(namePart); \ No newline at end of file diff --git a/BangumiRenamer/TMDbHelper.cs b/BangumiRenamer/TMDbHelper.cs deleted file mode 100644 index 9a9453d..0000000 --- a/BangumiRenamer/TMDbHelper.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Net; -using RestSharp; - -namespace BangumiRenamer; - -public class TMDbHelper -{ - private const string URL = "https://api.themoviedb.org/3/authentication"; - private const string APIKEY = "eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiI5OTExMDdhZjI1OTEzNTYyY2ZhMDY2MjJhNTI4NzNlMSIsIm5iZiI6MTcyMjY1MzY4My4xNjUsInN1YiI6IjY2YWQ5YmYzNTYzOGJjYmZmMWMwNWUzNiIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.BWFxLMJoAPl3wXNi_Gszx97WIPhbca3K33ASwjx_EPk"; - - public async Task SendRequest() - { - var options = new RestClientOptions(URL) - { - Proxy = new WebProxy("http://127.0.0.1:7897") - }; - var client = new RestClient(options); - - var request = new RestRequest(""); - request.AddHeader("accept", "application/json"); - request.AddHeader("Authorization",$"Bearer {APIKEY}"); - var response = await client.GetAsync(request); - - Console.WriteLine("{0}", response.Content); - } -} \ No newline at end of file diff --git a/Prompt.txt b/Prompt.txt new file mode 100644 index 0000000..d452268 --- /dev/null +++ b/Prompt.txt @@ -0,0 +1,98 @@ +你的任务是我提供一个文件的路径给你,你从其中提取信息填充到以下的json结构中告诉我。只需要告诉我一个json结构即可,不要说其它的。 +我会告诉你json的结构及各字段的含义和要求,以及一些示例以帮助你理解。 +json结构如下: + +```json +{ +    path: "", +    name: "", +    session: "", +    episode: "", +    group: "", +    type: "" +} +``` + +其中各字段含义为: ++ path:直接填入我提供的原始文件路径即可 ++ name:这个文件对应的剧集名。请进行一定程度的格式化,即如果其中单词使用的是其他符号进行分割,替换成空格 ++ session:这个文件对应的季度,如果文件路径不包含这个信息留空即可 ++ episode:这个文件对应哪一集,如果文件路径不包含这个信息留空即可 ++ group:这个文件可能是那个发布组发布的,如果文件路径不包含这个信息留空即可 ++ type: 文件可能是正片的视频文件,也可能是字幕文件。如果是视频文件就填`episode`,字幕文件填`subtitle`,其余填`others`。如果文件路径中包含"CD","SP","Scan"等字样表明它不属于正片的文件,请将类型统一设置为`others` +下面是一些示例: + +示例1: +输入:`[VCB-Studio] Shoujo Kageki Revue Starlight/[VCB-Studio] Shoujo Conte All Starlight [Ma10p_1080p]/[VCB-Studio] Shoujo Conte All Starlight [19][Ma10p_1080p][x265_flac].mkv` +输出: +```json +{ +    path: "[VCB-Studio] Shoujo Kageki Revue Starlight/[VCB-Studio] Shoujo Conte All Starlight [Ma10p_1080p]/[VCB-Studio] Shoujo Conte All Starlight [19][Ma10p_1080p][x265_flac].mkv", +    name: "Shoujo Conte All Starlight", +    session: "", +    episode: "19", +    group: "VCB-Studio", +    type: "episode" +} +``` + +示例2: +输入:`[VCB-Studio] Shoujo Kageki Revue Starlight/[DMG&MH&VCB-Studio] Shoujo Kageki Revue Starlight [Ma10p_1080p]/[DMG&MH&VCB-Studio] Shoujo Kageki Revue Starlight [03][Ma10p_1080p][x265_flac].tc.ass` +输出: +```json + +{ +    path: "[VCB-Studio] Shoujo Kageki Revue Starlight/[DMG&MH&VCB-Studio] Shoujo Kageki Revue Starlight [Ma10p_1080p]/[DMG&MH&VCB-Studio] Shoujo Kageki Revue Starlight [03][Ma10p_1080p][x265_flac].tc.ass", +    name: "Shoujo Kageki Revue Starlight", +    session: "", +    episode: "03", +    group: "VCB-Studio", +    type: "subtitle" +} + +``` + +示例3: +输入:`[Nekomoe kissaten&VCB-Studio] BanG Dream! It’s MyGO!!!!! [Ma10p_1080p]/Scans/Official Guidebook 「FOOTPRINTS」/021.jpeg` +输出: +```json +{ +    path: "[Nekomoe kissaten&VCB-Studio] BanG Dream! It’s MyGO!!!!! [Ma10p_1080p]/Scans/Official Guidebook 「FOOTPRINTS」/021.jpeg", +    name: "BanG Dream! It’s MyGO!!!!!", +    session: "", +    episode: "", +    group: "Nekomoe kissaten&VCB-Studio", +    type: "others" +} +``` + +示例4: +输入:`Lie.To.Me.S01.1080p.BluRay.x265-RARBG/Lie.To.Me.S01E01.1080p.BluRay.x265-RARBG.mp4` +输出: +```json +{ +    path: "Lie.To.Me.S01.1080p.BluRay.x265-RARBG/Lie.To.Me.S01E01.1080p.BluRay.x265-RARBG.mp4", +    name: "Lie To Me", +    session: "S01", +    episode: "E01", +    group: "RARBG", +    type: "episode" +} +``` + +示例5: +输入:`[Nekomoe kissaten&VCB-Studio] BanG Dream! It’s MyGO!!!!! [Ma10p_1080p]\SPs\[Nekomoe kissaten&VCB-Studio] BanG Dream! It’s MyGO!!!!! [NCED][Ma10p_1080p][x265_flac].mkv` +输出: +```json +{ +    path: "[Nekomoe kissaten&VCB-Studio] BanG Dream! It’s MyGO!!!!! [Ma10p_1080p]\SPs\[Nekomoe kissaten&VCB-Studio] BanG Dream! It’s MyGO!!!!! [NCED][Ma10p_1080p][x265_flac].mkv", +    name: "BanG Dream! It’s MyGO!!!!!", +    session: "", +    episode: "", +    group: "Nekomoe kissaten&VCB-Studio", +    type: "others" +} +``` + +不需要分析路径里面的信息的含义,只要按照要求确认好哪部分应该是标题,那部分应该是集数,季数等信息即可。 +清楚了会回答我明白了,然后我们开始。 \ No newline at end of file diff --git a/ds.py b/ds.py new file mode 100644 index 0000000..972fe52 --- /dev/null +++ b/ds.py @@ -0,0 +1,16 @@ +# Please install OpenAI SDK first: `pip3 install openai` + +from openai import OpenAI + +client = OpenAI(api_key="sk-9cfe4cd39c824a108c5904db8e38a783", base_url="https://api.deepseek.com") + +response = client.chat.completions.create( + model="deepseek-chat", + messages=[ + {"role": "system", "content": "You are a helpful assistant"}, + {"role": "user", "content": "Hello"}, + ], + stream=False +) + +print(response.choices[0].message.content) \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..40e4336 --- /dev/null +++ b/main.py @@ -0,0 +1,20 @@ +import ollama + + +if __name__ == "__main__": + pass + + # 读取整个文件内容 + content = file.read() + + # 打印文件内容 + print(content) + + # 关闭文件 (非常重要!) + file.close() + + response = ollama.generate( + model="gemma3:12b-it-q8_0", + prompt="我上一个问题是什么" + ) + print(response["response"]) \ No newline at end of file