From 613f33ea7df7b17e0fe425919031578f6c8b3ace Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sun, 26 Apr 2020 18:34:28 -0400 Subject: [PATCH] stuff --- .gitattributes | 63 ++++++++++++++++++++++++++ App.config | 6 +++ Program.cs | 78 +++++++++++++++++++++++++++++++++ Properties/AssemblyInfo.cs | 36 +++++++++++++++ chandl.csproj | 90 ++++++++++++++++++++++++++++++++++++++ chandl.sln | 25 +++++++++++ packages.config | 5 +++ 7 files changed, 303 insertions(+) create mode 100644 .gitattributes create mode 100644 App.config create mode 100644 Program.cs create mode 100644 Properties/AssemblyInfo.cs create mode 100644 chandl.csproj create mode 100644 chandl.sln create mode 100644 packages.config diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/App.config b/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..ee5f9ab --- /dev/null +++ b/Program.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Net; +using FChan.Library; +using System.IO; +using Newtonsoft.Json; + +namespace chandl +{ + class Program + { + public static string localDirectory = Environment.CurrentDirectory; + + public static Tuple, int, string> GetThreadImages(string board, int threadNumber) + { + List imgList = new List(); + try + { + var a = Chan.GetThread(board, threadNumber); + } + catch (NullReferenceException) + { + Console.WriteLine("Invalid thread"); + throw new NullReferenceException(); + } + Thread threadObject = Chan.GetThread(board, threadNumber); + foreach (Post postObject in threadObject.Posts) + { + if (postObject.FileName != 0) + { + imgList.Add(postObject.FileName + postObject.FileExtension); + } + } + return Tuple.Create(imgList, threadNumber, board); + } + public static void DownloadImages(List imageList, int directoryName, string boardName) + { + string rootThreadDir = localDirectory + "\\threads"; + string threadDir = rootThreadDir + "\\" + directoryName.ToString(); + if (!Directory.Exists(rootThreadDir)) + { + Directory.CreateDirectory(rootThreadDir); + Console.WriteLine("Root thread directory was not found. Creating it now."); + } + if (!Directory.Exists(threadDir)) + { + Directory.CreateDirectory(threadDir); + } + else + { + Console.WriteLine("Thread directory "+threadDir+" already exists. Continue? [y/n]"); + string response = Console.ReadLine(); + if (response == "n") + { + Console.WriteLine("Stopping..."); + System.Environment.Exit(1); + } + } + WebClient webclient = new WebClient(); + foreach (string file in imageList) + { + string fileURL = "https://i.4cdn.org/" + boardName + "/" + file; + Console.WriteLine("Attempting to download " + fileURL); + webclient.DownloadFile(fileURL, threadDir + "\\" + file); + Console.WriteLine("File " + file + " downloaded."); + } + } + static void Main(string[] args) + { + Console.WriteLine("Running from " + localDirectory); + Console.WriteLine("Downloading images from thread " + args[0] + " on board " + Int32.Parse(args[1])); + var images = GetThreadImages(args[0], Int32.Parse(args[1])); + DownloadImages(images.Item1, images.Item2, images.Item3); + Console.WriteLine("Job Complete!"); + Console.Read(); + } + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..da3bcec --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("chandl")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("chandl")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("7dd97a19-303b-4d40-9f01-b3557a40a2bf")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/chandl.csproj b/chandl.csproj new file mode 100644 index 0000000..e953a99 --- /dev/null +++ b/chandl.csproj @@ -0,0 +1,90 @@ + + + + + Debug + AnyCPU + {7DD97A19-303B-4D40-9F01-B3557A40A2BF} + Exe + chandl + chandl + v4.7.2 + 512 + true + true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + packages\FChan.Library.2.0.1\lib\netstandard2.0\FChan.Library.dll + + + packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + + + False + Microsoft .NET Framework 4.7.2 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + + \ No newline at end of file diff --git a/chandl.sln b/chandl.sln new file mode 100644 index 0000000..a952cc2 --- /dev/null +++ b/chandl.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29926.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "chandl", "chandl.csproj", "{7DD97A19-303B-4D40-9F01-B3557A40A2BF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7DD97A19-303B-4D40-9F01-B3557A40A2BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7DD97A19-303B-4D40-9F01-B3557A40A2BF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7DD97A19-303B-4D40-9F01-B3557A40A2BF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7DD97A19-303B-4D40-9F01-B3557A40A2BF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FFB294B1-0048-491A-B13F-95BBD6E051D2} + EndGlobalSection +EndGlobal diff --git a/packages.config b/packages.config new file mode 100644 index 0000000..af9fce7 --- /dev/null +++ b/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file