added upload for storage
This commit is contained in:
parent
d59a32e337
commit
4bf5797ed0
|
@ -1,5 +1,5 @@
|
||||||
<Properties StartupConfiguration="{E26F8159-6B4B-4660-A7A4-D0333DFEF0DD}|Default" NuGet.AddPackagesDialog.IncludePrerelease="True">
|
<Properties StartupConfiguration="{E26F8159-6B4B-4660-A7A4-D0333DFEF0DD}|Default" NuGet.AddPackagesDialog.IncludePrerelease="True">
|
||||||
<MonoDevelop.Ide.Workbench ActiveDocument="Broadcast.cs">
|
<MonoDevelop.Ide.Workbench ActiveDocument="Program.cs">
|
||||||
<Files>
|
<Files>
|
||||||
<File FileName="TYTD.Api/Server/Models/InfoType.cs" Line="155" Column="47" />
|
<File FileName="TYTD.Api/Server/Models/InfoType.cs" Line="155" Column="47" />
|
||||||
<File FileName="TYTD.Api/Server/Functions/Downloader.cs" Line="69" Column="28" />
|
<File FileName="TYTD.Api/Server/Functions/Downloader.cs" Line="69" Column="28" />
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
<File FileName="TYTD.Api/Server/Models/SavedVideo.cs" Line="8" Column="1" />
|
<File FileName="TYTD.Api/Server/Models/SavedVideo.cs" Line="8" Column="1" />
|
||||||
<File FileName="TYTD.Api/Server/Models/InfomationQueueItem.cs" Line="280" Column="42" />
|
<File FileName="TYTD.Api/Server/Models/InfomationQueueItem.cs" Line="280" Column="42" />
|
||||||
<File FileName="TYTD.Api/Server/Functions/ffmpeg.cs" Line="5" Column="15" />
|
<File FileName="TYTD.Api/Server/Functions/ffmpeg.cs" Line="5" Column="15" />
|
||||||
<File FileName="Program.cs" Line="61" Column="13" />
|
<File FileName="Program.cs" Line="1561" Column="1" />
|
||||||
<File FileName="TYTD.Api/MyClass.cs" Line="225" Column="46" />
|
<File FileName="TYTD.Api/MyClass.cs" Line="225" Column="46" />
|
||||||
<File FileName="TYTD.Api/Server/Models/SavedChannel.cs" Line="6" Column="10" />
|
<File FileName="TYTD.Api/Server/Models/SavedChannel.cs" Line="6" Column="10" />
|
||||||
<File FileName="TYTD.Api/Server/Models/SavedPlaylist.cs" Line="7" Column="1" />
|
<File FileName="TYTD.Api/Server/Models/SavedPlaylist.cs" Line="7" Column="1" />
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
<File FileName="../../../usr/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets" Line="2101" Column="5" />
|
<File FileName="../../../usr/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets" Line="2101" Column="5" />
|
||||||
<File FileName="TYTD.Api/Server/Models/IEnumerator.cs" Line="1" Column="1" />
|
<File FileName="TYTD.Api/Server/Models/IEnumerator.cs" Line="1" Column="1" />
|
||||||
<File FileName="TYTD.Api/SimpleHttpExtensions.cs" Line="17" Column="19" />
|
<File FileName="TYTD.Api/SimpleHttpExtensions.cs" Line="17" Column="19" />
|
||||||
<File FileName="Broadcast.cs" Line="11" Column="9" />
|
<File FileName="Broadcast.cs" Line="3" Column="15" />
|
||||||
</Files>
|
</Files>
|
||||||
<Pads>
|
<Pads>
|
||||||
<Pad Id="ProjectPad">
|
<Pad Id="ProjectPad">
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
</Node>
|
</Node>
|
||||||
<Node name="youtube-downloader" expanded="True">
|
<Node name="youtube-downloader" expanded="True">
|
||||||
<Node name="Properties" expanded="True" />
|
<Node name="Properties" expanded="True" />
|
||||||
<Node name="Broadcast.cs" selected="True" />
|
<Node name="Program.cs" selected="True" />
|
||||||
</Node>
|
</Node>
|
||||||
</Node>
|
</Node>
|
||||||
</State>
|
</State>
|
||||||
|
|
26
Program.cs
26
Program.cs
|
@ -43,6 +43,7 @@ namespace TYTD
|
||||||
static string webSitePath;
|
static string webSitePath;
|
||||||
static void Main(string[] arg)
|
static void Main(string[] arg)
|
||||||
{
|
{
|
||||||
|
|
||||||
Directory.CreateDirectory(Path.Combine("config", "apidll"));
|
Directory.CreateDirectory(Path.Combine("config", "apidll"));
|
||||||
Downloader.GetManifest = GetManifest;
|
Downloader.GetManifest = GetManifest;
|
||||||
Thread t = new Thread(new ThreadStart(() => {
|
Thread t = new Thread(new ThreadStart(() => {
|
||||||
|
@ -133,7 +134,7 @@ namespace TYTD
|
||||||
/* Playlist */
|
/* Playlist */
|
||||||
Downloader.RouteAdd("/api/AddPlaylistOnly/{Id}","Playlist","Add playlist, dont download videos\nParams:\n{Id}: Playlist Id or Url to download", AddPlaylistOnly);
|
Downloader.RouteAdd("/api/AddPlaylistOnly/{Id}","Playlist","Add playlist, dont download videos\nParams:\n{Id}: Playlist Id or Url to download", AddPlaylistOnly);
|
||||||
Downloader.RouteAdd("/api/RedownloadPlaylist/{Id}", "Playlist", "Redownload Playlist Entries (Wont Update Playlist, use /api/AddPlaylist/ for that)\nThis will download playlist if not already done, or if playlist is empty\n(SD, Premuxed Video)\nParams:\n{Id}: Existing Playlist Id",(HttpAction)RedownloadPlaylist);
|
Downloader.RouteAdd("/api/RedownloadPlaylist/{Id}", "Playlist", "Redownload Playlist Entries (Wont Update Playlist, use /api/AddPlaylist/ for that)\nThis will download playlist if not already done, or if playlist is empty\n(SD, Premuxed Video)\nParams:\n{Id}: Existing Playlist Id",(HttpAction)RedownloadPlaylist);
|
||||||
Downloader.RouteAdd("/api/RedownloadPlaylistRes/{R}/{Id}", "Playlist", "Redownload Playlist Entries (Wont Update Playlist, use /api/AddPlaylist/ for that)\nThis will download playlist if not already done, or if playlist is empty\nParams:\n{Id}: Existing Playlist Id\n{R}: 0=HD (Muxed using ffmpeg), 1=SD (Premuxed Video), 2=Audio only", (HttpAction)RedownloadPlaylistRes);
|
Downloader.RouteAdd("/api/RedownloadPlaylistRes/{R}/{Id}", "Playlist", "Redownload Playlist Entries (Wont Update Playlist, use /api/AddPlaylist/ for that)\nThis will download playlist if not already done, or if playlist is empty\nParams:\n{Id}: Existing Playlist Id\n{R}: 0=HD (Muxed using ffmpeg), 1=SD (Premuxed Video), 2=Audio only", (HttpAction)RedownloadPlaylistRes, "GET");
|
||||||
Downloader.RouteAdd("/api/AddPlaylist/{Id}","Playlist", "Add Playlist to downloader\nIt will be SD (Premuxed Video)\nParams:\n{Id}: The Id or URL for the Playlist", (HttpAction)AddPlaylist);
|
Downloader.RouteAdd("/api/AddPlaylist/{Id}","Playlist", "Add Playlist to downloader\nIt will be SD (Premuxed Video)\nParams:\n{Id}: The Id or URL for the Playlist", (HttpAction)AddPlaylist);
|
||||||
Downloader.RouteAdd("/api/AddPlaylistRes/{R}/{Id}","Playlist", "Add Playlist to downloader\nParams:\n{R}:0=HD (Muxed using ffmpeg), 1=SD (Premuxed Video), 2=Audio only\n{Id}: The Id or URL for the playlist", (HttpAction)AddPlaylistRes);
|
Downloader.RouteAdd("/api/AddPlaylistRes/{R}/{Id}","Playlist", "Add Playlist to downloader\nParams:\n{R}:0=HD (Muxed using ffmpeg), 1=SD (Premuxed Video), 2=Audio only\n{Id}: The Id or URL for the playlist", (HttpAction)AddPlaylistRes);
|
||||||
Downloader.RouteAdd("/api/PersonalPlaylist/{PlaylistName}","PersonalPlaylist","Create personal playlist with name",(HttpAction)PersonalPlaylist);
|
Downloader.RouteAdd("/api/PersonalPlaylist/{PlaylistName}","PersonalPlaylist","Create personal playlist with name",(HttpAction)PersonalPlaylist);
|
||||||
|
@ -179,6 +180,8 @@ namespace TYTD
|
||||||
Downloader.RouteAdd("/api/Storage/DirectoryExists/{Path}", "Storage", "returns \"true\" if directory exists or \"false\" if not",(HttpAction)StorageDirectoryExists);
|
Downloader.RouteAdd("/api/Storage/DirectoryExists/{Path}", "Storage", "returns \"true\" if directory exists or \"false\" if not",(HttpAction)StorageDirectoryExists);
|
||||||
Downloader.RouteAdd("/api/Storage/FileExists/{Path}","Storage","returns \"true\" if file exists or \"false\" if not", (HttpAction)StorageFileExists);
|
Downloader.RouteAdd("/api/Storage/FileExists/{Path}","Storage","returns \"true\" if file exists or \"false\" if not", (HttpAction)StorageFileExists);
|
||||||
Downloader.RouteAdd("/api/Storage/File/{Path}","Storage","Get file based on working directory", (HttpAction)StorageFile);
|
Downloader.RouteAdd("/api/Storage/File/{Path}","Storage","Get file based on working directory", (HttpAction)StorageFile);
|
||||||
|
Downloader.RouteAdd("/api/Storage/File/{Path}", "Storage", "Upload file over put (not Website Directory)", (HttpAction)UploadStorageFilePut, "PUT");
|
||||||
|
|
||||||
Downloader.RouteAdd("/api/Storage/Video/{Id}","Storage","",(HttpAction)Video);
|
Downloader.RouteAdd("/api/Storage/Video/{Id}","Storage","",(HttpAction)Video);
|
||||||
Downloader.RouteAdd("/api/Storage/VideoRes/{Res}/{Id}","Storage","Download Video to Computer from Downloader\nParams:\n{Res}: 0=HD (Muxed using ffmpeg), 1=SD (Premuxed Video), 2=Audio only\n{Id}: Video Id to Download",(HttpAction)VideoRes);
|
Downloader.RouteAdd("/api/Storage/VideoRes/{Res}/{Id}","Storage","Download Video to Computer from Downloader\nParams:\n{Res}: 0=HD (Muxed using ffmpeg), 1=SD (Premuxed Video), 2=Audio only\n{Id}: Video Id to Download",(HttpAction)VideoRes);
|
||||||
Downloader.RouteAdd("/api/upload/","Storage","Upload file via POST", (HttpAction)UploadFiles, "POST");
|
Downloader.RouteAdd("/api/upload/","Storage","Upload file via POST", (HttpAction)UploadFiles, "POST");
|
||||||
|
@ -1153,6 +1156,27 @@ namespace TYTD
|
||||||
{
|
{
|
||||||
rp.AsText(ApiLoader.Page);
|
rp.AsText(ApiLoader.Page);
|
||||||
}
|
}
|
||||||
|
private static void UploadStorageFilePut(HttpListenerRequest request,HttpListenerResponse resp,Dictionary<string,string> args)
|
||||||
|
{
|
||||||
|
string path = System.Web.HttpUtility.UrlDecode(args["Path"]).Split(new char[] { '?' }, StringSplitOptions.RemoveEmptyEntries)[0];
|
||||||
|
|
||||||
|
bool exists = File.Exists(path);
|
||||||
|
using (var instr = request.InputStream)
|
||||||
|
{
|
||||||
|
using (var outStr = File.Create(path))
|
||||||
|
{
|
||||||
|
instr.CopyTo(outStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (exists)
|
||||||
|
{
|
||||||
|
resp.WithCode(HttpStatusCode.NoContent);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
resp.WithCode(HttpStatusCode.Created);
|
||||||
|
}
|
||||||
|
}
|
||||||
private static void UploadFilePut(HttpListenerRequest request, HttpListenerResponse response, Dictionary<string, string> arguments)
|
private static void UploadFilePut(HttpListenerRequest request, HttpListenerResponse response, Dictionary<string, string> arguments)
|
||||||
{
|
{
|
||||||
string p = System.Web.HttpUtility.UrlDecode(arguments["Path"]).Split(new char[] { '?' }, StringSplitOptions.RemoveEmptyEntries)[0];
|
string p = System.Web.HttpUtility.UrlDecode(arguments["Path"]).Split(new char[] { '?' }, StringSplitOptions.RemoveEmptyEntries)[0];
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue