Skip to content
This repository has been archived by the owner on Jan 17, 2022. It is now read-only.

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
dreanor committed Dec 19, 2016
0 parents commit 361e90c
Show file tree
Hide file tree
Showing 14 changed files with 994 additions and 0 deletions.
217 changes: 217 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
#################
## Eclipse
#################

*.pydevproject
.project
.metadata
.nuget
packages/
bin/
build/
dropboxrelease/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# PDT-specific
.buildpath


#################
## Visual Studio
#################

## 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
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.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

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.Publish.xml
*.pubxml

# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/

# Windows Azure Build Output
csx
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.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 crap
.DS_Store


#############
## Python
#############

*.py[co]

# Packages
*.egg
*.egg-info
dist/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox

#Translations
*.mo

#Mr Developer
.mr.developer.cfg
22 changes: 22 additions & 0 deletions TorrentBrowser.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.25928.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TorrentBrowser", "TorrentBrowser\TorrentBrowser.csproj", "{3C4564BA-38DD-4A77-98B7-BA406F73C357}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3C4564BA-38DD-4A77-98B7-BA406F73C357}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C4564BA-38DD-4A77-98B7-BA406F73C357}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C4564BA-38DD-4A77-98B7-BA406F73C357}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C4564BA-38DD-4A77-98B7-BA406F73C357}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions TorrentBrowser/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
</configuration>
69 changes: 69 additions & 0 deletions TorrentBrowser/Form1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Windows.Forms;

namespace TorrentBrowser
{
public partial class Form1 : Form
{
const string DownloadPage = "https://www.nyaa.se/?page=download&";

public Form1()
{
InitializeComponent();
}

private void downloadCurrentSearchToolStripMenuItem_Click(object sender, EventArgs e)
{
string sourcePage = webBrowser1.DocumentText;

List<string> torrents = GetTorrents(sourcePage);
DownloadTorrents(torrents);
}

private static List<string> GetTorrents(string sourcePage)
{
List<string> torrents = new List<string>();
int index = 0;
do
{
index = sourcePage.IndexOf("tid=", index);
if (index != -1)
{
var endOfTid = sourcePage.IndexOf("\"", index);
var difference = endOfTid - index;
var tid = sourcePage.Substring(index, difference);

torrents.Add(DownloadPage + tid);
index++;
}
} while (index != -1);

torrents = torrents.Distinct().ToList();
return torrents;
}

private static void DownloadTorrents(List<string> torrents)
{
using (WebClient webClient = new WebClient())
{
int count = 1;
foreach (var torrent in torrents)
{
string name = $"{count}.torrent";
webClient.DownloadFile(torrent, name);
Process.Start(name);
count++;
}
}
}

private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("https://www.nyaa.se/?page=search&cats=1_37&filter=2");
}
}
}
Loading

0 comments on commit 361e90c

Please sign in to comment.