Everything works but TorrentManager (TorrentManager is being started)

This commit is contained in:
Mike Nolan 2022-01-19 07:05:40 -06:00
commit 644d07ea5b
289 changed files with 8484 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "tytd-server"]
path = tytd-server
url = https://gitlab.tesses.cf/tesses50/tytd-server

View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{75DF3D35-07A2-4CA9-A5EA-C80A4FFC61DA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Autofetch_YT</RootNamespace>
<AssemblyName>Autofetch YT</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Hyperlinq">
<Version>1.0.7</Version>
</PackageReference>
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces">
<Version>6.0.0-preview.7.21377.19</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.1</Version>
</PackageReference>
<PackageReference Include="Simple-HTTP">
<Version>1.0.6</Version>
</PackageReference>
<PackageReference Include="YoutubeExplode">
<Version>6.0.5</Version>
</PackageReference>
<PackageReference Include="AngleSharp">
<Version>0.16.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\tytd-server\TYTD.Api\TYTD.Api.csproj">
<Project>{B859C3EE-A821-4C36-8A55-729E79194CF4}</Project>
<Name>TYTD.Api</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

268
Autofetch YT/Class1.cs Normal file
View File

@ -0,0 +1,268 @@
using SimpleHttp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using TYTD;
using Newtonsoft.Json;
using System.IO;
using YoutubeExplode.Channels;
using Hyperlinq;
namespace Autofetch_YT
{
public class RSSState
{
public RSSState()
{
ReqDuration = new TimeSpan(0,30, 0);
}
public Dictionary<string,YoutubeRSS> VideoRSS { get; set; }
public TimeSpan ReqDuration { get; set; }
}
public class AutofetchYT : Api
{
RSSState state;
public override void OnStart()
{
Route.Add("/api/Extensions/AutofetchYT/", (HttpAction)Autofetch);
Route.Add("/api/Extensions/AutofetchYT/change", (HttpAction)AutofetchChange, "POST");
Load();
SetTimer(state.ReqDuration);
}
public override IEnumerable<KeyValuePair<string, string>> GetUrls()
{
yield return new KeyValuePair<string, string>("AutoFetch", "api/Extensions/AutofetchYT/");
}
protected override void TimerElapsed()
{
foreach(var item in state.VideoRSS)
{
item.Value.Scan();
}
}
public HElement GetSite()
{
return H.html(
H.head(
H.meta(e => e.charset("UTF8")),
H.meta(e => e.http_equiv("X-UA-Compatible").content("IE=edge")),
H.meta(e => e.name("viewport").content("width=device-width, initial-scale=1.0")),
H.title("Autofetch YT"),
H.link(e => e.href("https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css").rel("stylesheet")),
H.script(e => e.src("https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js")),
H.script(e => e.src("https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js")),
H.link(e => e.href("../../favicon.ico").rel("shortcut icon").type("image/x-icon").Custom("crossorigin","use-credentials"))
),
H.body(
H.div(e=>e.css("container"),
H.h1("Autofetch YT"),
H.ul(e=>e.css("nav nav-tabs"),
H.li(e=>e.css("active"),
H.a(e=>e.Custom("data-toggle","tab").href("#addchannel"),"Add")
),
H.li(
H.a(e=> e.Custom("data-toggle", "tab").href("#channels"),"Channels")
),
H.li(
H.a(e => e.Custom("data-toggle", "tab").href("#more"), "More")
)
),
H.div(e=>e.css("tab-content"),
H.div(e=>e.id("addchannel").css("tab-pane fad in active"),
H.br(),
H.div(e=>e.css("container"),
H.form(e=>e.action("change").method("POST"),
H.input(e=>e.type("hidden").name("operation").value("add")),
H.input(e=>e.type("text").placeholder("Name").name("key")),
H.br(),H.br(),
H.input(e=>e.type("text").placeholder("Channel ID or URL").name("value")),
H.br(),H.br(),
H.input(e=>e.type("submit").value("Add Channel").css("btn btn-primary"))
)
)
),
H.div(e=>e.id("channels").css("tab-pane fade"),
H.br(),
H.div(e=>e.css("container"),
H.table(e=>e.css("table table-striped"),
H.thead(
H.tr(
H.th("Name"),
H.th("Channel Url"),
H.th("Delete")
)
),
H.tbody(
from item in state.VideoRSS
select RSSTr(item)
)
)
)
),
H.div(e => e.id("more").css("tab-pane fade"),
H.br(),
H.div(e => e.css("container"),
H.form(e=>e.action("change").method("POST"),
H.h1("Clear All Channels"),
H.input(e=>e.type("hidden").name("operation").value("clear")),
H.input(e=>e.type("submit").value("Clear").css("btn btn-danger"))
),
H.form(e => e.action("change").method("POST"),
H.h1("Interval"),
H.input(e=>e.type("hidden").name("operation").value("setinterval")),
H.input(e=>e.type("text").name("interval").value(state.ReqDuration.ToString())),
H.br(),H.br(),
H.input(e=>e.type("submit").value("Set Interval").css("btn btn-primary"))
)
)
)
)
)
));
}
public HElement RSSTr(KeyValuePair<string,YoutubeRSS> item)
{ string url = $"https://www.youtube.com/channel/{item.Value.ID}";
return H.tr(
H.td(item.Key),
H.td(H.A(url, url)),
H.td(
H.form(
H.input(e => e.type("submit").css("btn-danger").value("X")),
H.input(e => e.type("hidden").name("operation").value("delete")),
H.input(e => e.type("hidden").name("key").value(item.Value.ID)
)
)));
}
public void Autofetch(HttpListenerRequest req, HttpListenerResponse resp, Dictionary<string, string> args)
{
resp.AsText(GetSite().ToString());
}
public void AutofetchChange(HttpListenerRequest req, HttpListenerResponse resp, Dictionary<string, string> args)
{
TimerEnabled = false;
req.ParseBody(args);
if (args.ContainsKey("operation"))
{
string operation = args["operation"];
switch (operation)
{
case "add":
if(args.ContainsKey("key") && args.ContainsKey("value"))
{
string key = args["key"];
string value = args["value"];
ChannelId? id = ChannelId.TryParse(value);
if(id.HasValue)
{
state.VideoRSS.Add(key, new YoutubeRSS(this, id.Value));
}
}
break;
case "delete":
if (args.ContainsKey("key"))
{
string key = args["key"];
if(state.VideoRSS.ContainsKey(key))
{
state.VideoRSS.Remove(key);
}
}
break;
case "clear":
state.VideoRSS.Clear();
break;
case "setinterval":
if (args.ContainsKey("interval"))
{
TimeSpan span;
if (TimeSpan.TryParse(args["interval"], out span))
{
state.ReqDuration = span;
}
}
break;
}
}
Save();
resp.AsText("<script>window.location.href=\".\"</script>");
}
public void Save()
{
string videoInfo = Path.Combine(StorageLocation, "autofetch.json");
File.WriteAllText(videoInfo, JsonConvert.SerializeObject(state));
SetTimer(state.ReqDuration);
}
public void Load()
{
string videoInfo = Path.Combine(StorageLocation, "autofetch.json");
if (File.Exists(videoInfo))
{
state = JsonConvert.DeserializeObject<RSSState>(File.ReadAllText(videoInfo));
foreach(var item in state.VideoRSS)
{
item.Value.SetApi(this);
}
}
else
{
state = new RSSState();
state.VideoRSS = new Dictionary<string, YoutubeRSS>();
}
}
}
public class YoutubeRSS
{
Api api;
public string ID { get; set; }
public YoutubeRSS(Api api,string id)
{
this.api = api;
this.ID = id;
// UCZkURf9tDolFOeuw_4RD7XQ
}
public YoutubeRSS()
{
}
public void SetApi(Api api)
{
this.api = api;
}
public void Scan()
{
var xml = System.Xml.XmlReader.Create("https://www.youtube.com/feeds/videos.xml?channel_id=" + this.ID);
var feed = System.ServiceModel.Syndication.SyndicationFeed.Load(xml);
foreach (var item in feed.Items)
{
string id = item.Id;
api.AddItem(id.Substring("yt:videoId".Length - 1));
}
}
}
}

View File

@ -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("Autofetch YT")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Autofetch YT")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[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("75df3d35-07a2-4ca9-a5ea-c80a4ffc61da")]
// 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")]

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More