diff --git a/Tesses.YouTubeDownloader.Server/Class1.cs b/Tesses.YouTubeDownloader.Server/Class1.cs
index a5332cc..eac6299 100644
--- a/Tesses.YouTubeDownloader.Server/Class1.cs
+++ b/Tesses.YouTubeDownloader.Server/Class1.cs
@@ -12,6 +12,7 @@ using YoutubeExplode.Playlists;
using YoutubeExplode.Channels;
using Tesses.Extensions;
using YoutubeExplode.Videos.Streams;
+using Tesses.WebServer.Swagme;
namespace Tesses.Extensions
{
@@ -32,16 +33,7 @@ namespace Tesses.YouTubeDownloader.Server
{
using Tesses.YouTubeDownloader;
-public class Progress
-{
- public long Length {get;set;}
- public double Percent {get;set;}
-
- public SavedVideo Video {get;set;}
- public bool StartEvent {get;set;}
- public bool StopEvent {get;set;}
-}
internal static class B64
{
public static string Base64UrlEncodes(string arg)
@@ -855,45 +847,61 @@ internal static class B64
}
}
}
- internal class ApiV2Server : RouteServer
+ internal class ApiV2Server
{
+ public SwagmeServer Swagme {get;private set;}=new SwagmeServer();
IDownloader Downloader;
public ApiV2Server(IDownloader downloader)
{
- this.Downloader=downloader;
- AddBoth("/event",Event);
- AddBoth("/CancelDownload",Cancel);
- AddBoth("/Search",Search);
- AddBoth("/AddItem",AddItem);
- AddBoth("/AddChannel",AddChannel);
- AddBoth("/AddUser",AddUser);
- AddBoth("/AddPlaylist",AddPlaylist);
- AddBoth("/AddVideo",AddVideo);
- AddBoth("/AddFile",AddFile);
- AddBoth("/Progress",ProgressFunc);
- AddBoth("/QueueList",QueueList);
- AddBoth("/subscribe",Subscribe);
- AddBoth("/resubscribe",Resubscribe);
- AddBoth("/unsubscribe",Unsubscribe);
- AddBoth("/subscriptions",Subscriptions);
- AddBoth("/Subscribe",Subscribe);
- AddBoth("/Resubscribe",Resubscribe);
- AddBoth("/Unsubscribe",Unsubscribe);
- AddBoth("/Subscriptions",Subscriptions);
- AddBoth("/AddToList",AddToList);
- AddBoth("/DeleteFromList",DeleteFromList);
- Add("/ReplaceList",ReplaceList,"POST");
- AddBoth("/DeleteList",DeleteList);
- AddBoth("/SetResolutionInList",SetResolutionInList);
+ Swagme.AbsoluteUrl=true;
- Add("/export/everything.json",Everything_Export,"GET");
- Add("/export/videos.json",VideosExport,"GET");
- Add("/export/playlists.json",PlaylistsExport,"GET");
- Add("/export/channels.json",ChannelsExport,"GET");
- Add("/export/filedownloads.json",FilesExport,"GET");
- Add("/export/subscriptions.json",SubscriptionsExport,"GET");
- Add("/export/personal_lists.json",PersonalListsExport,"GET");
+ this.Downloader=downloader;
+ /*Adding items*/
+ AddBoth("/AddVideo",AddVideo,new SwagmeDocumentation("/AddVideo?v=jNQXAC9IVRw&res=PreMuxed","Add youtube video","v: Video Id Or encodeUriComponent Url
res: NoDownload=Do not download clip but just info, Mux=Requires conversion, PreMuxed=Does not require conversion, AudioOnly=Best audio only, VideoOnly=Best video only"),"Adding items");
+ AddBoth("/AddPlaylist",AddPlaylist,new SwagmeDocumentation("/AddPlaylist?id=PLgXAgLm6Kre7M3c8G2OlQTG-PETLHs4Vd&res=PreMuxed","Add youtube playlist","id: Playlist Id Or encodeUriComponent Url
res: NoDownload=Do not download clip but just info, Mux=Requires conversion, PreMuxed=Does not require conversion, AudioOnly=Best audio only, VideoOnly=Best video only"),"Adding items");
+ AddBoth("/AddChannel",AddChannel,new SwagmeDocumentation("/AddChannel?id=UC4QobU6STFB0P71PMvOGN5A&res=PreMuxed","Add youtube channel","id: YouTube Channel Id Or encodeUriComponent Url
res: NoDownload=Do not download clip but just info, Mux=Requires conversion, PreMuxed=Does not require conversion, AudioOnly=Best audio only, VideoOnly=Best video only"),"Adding items");
+ AddBoth("/AddUser",AddUser,new SwagmeDocumentation("/AddUser?id=jawed&res=PreMuxed","Add youtube user","id: YouTube Channel Name Or encodeUriComponent Url
res: NoDownload=Do not download clip but just info, Mux=Requires conversion, PreMuxed=Does not require conversion, AudioOnly=Best audio only, VideoOnly=Best video only"),"Adding items");
+ AddBoth("/AddItem",AddItem,new SwagmeDocumentation("/AddItem?v=jNQXAC9IVRw&res=PreMuxed","Add any type of item","v: Media Id Or encodeUriComponent Url
res: NoDownload=Do not download clip but just info, Mux=Requires conversion, PreMuxed=Does not require conversion, AudioOnly=Best audio only, VideoOnly=Best video only"),"Adding items");
+ AddBoth("/AddFile",AddFile,new SwagmeDocumentation("/AddFile?url=https%3A%2F%2Ftesses.cf%2Fimages%2Frvl.jpg&download=true","Add normal file download","url: Url to file
download: whether to download file"),"Adding items");
+ /*Getting status*/
+ AddBoth("/event",Event,new SwagmeDocumentation("Server sent events","Returns events with json"),"Getting status");
+ AddBoth("/Progress",ProgressFunc,new SwagmeDocumentation("Get video progress","More Info"),"Getting status");
+ AddBoth("/QueueList",QueueList,new SwagmeDocumentation("Get items in Queue","More Info"),"Getting status");
+
+ /*Subscriptions*/
+ AddBoth("/Subscribe",Subscribe,new SwagmeDocumentation("/Subscribe?id=UC4QobU6STFB0P71PMvOGN5A&conf=NotifyAndDownload","Subscribe to youtuber","id: Channel Id
conf: DoNothing=Disable, GetInfo=Just Get info, Notify=Bell event, Download=Download video no bell event, NotifyAndDownload=Download video with bell event"),"Subscriptions");
+ AddBoth("/subscribe",Subscribe,new SwagmeDocumentation("/subscribe?id=UC4QobU6STFB0P71PMvOGN5A&conf=NotifyAndDownload","Subscribe to youtuber","id: Channel Id
conf: DoNothing=Disable, GetInfo=Just Get info, Notify=Bell event, Download=Download video no bell event, NotifyAndDownload=Download video with bell event"),"Subscriptions");
+ AddBoth("/Resubscribe",Resubscribe,new SwagmeDocumentation("/Resubscribe?id=UC4QobU6STFB0P71PMvOGN5A&conf=Download","Change subscription settings","id: Channel Id
conf: DoNothing=Disable, GetInfo=Just Get info, Notify=Bell event, Download=Download video no bell event, NotifyAndDownload=Download video with bell event"),"Subscriptions");
+ AddBoth("/resubscribe",Resubscribe,new SwagmeDocumentation("/resubscribe?id=UC4QobU6STFB0P71PMvOGN5A&conf=Download","Change subscription settings","id: Channel Id
conf: DoNothing=Disable, GetInfo=Just Get info, Notify=Bell event, Download=Download video no bell event, NotifyAndDownload=Download video with bell event"),"Subscriptions");
+ AddBoth("/Unsubscribe",Unsubscribe,new SwagmeDocumentation("/Unsubscribe?id=UC4QobU6STFB0P71PMvOGN5A","Unsubscribe from youtuber","id: Channel Id"),"Subscriptions");
+ AddBoth("/unsubscribe",Unsubscribe,new SwagmeDocumentation("/unsubscribe?id=UC4QobU6STFB0P71PMvOGN5A","Unsubscribe from youtuber","id: Channel Id"),"Subscriptions");
+ AddBoth("/Subscriptions",Subscriptions,new SwagmeDocumentation("Get subscriptions","Returned Json array
Id: Channel Id
BellInfo: 0=DoNothing, 1=GetInfo, 3=Notify, 5=Download, 7=NotifyAndDownload"),"Subscriptions");
+ AddBoth("/subscriptions",Subscriptions,new SwagmeDocumentation("Get subscriptions","Returned Json array
Id: Channel Id
BellInfo: 0=DoNothing, 1=GetInfo, 3=Notify, 5=Download, 7=NotifyAndDownload"),"Subscriptions");
+
+
+ /*Personal Lists*/
+ AddBoth("/AddToList",AddToList,new SwagmeDocumentation("/AddToList?name=SomeList&v=jNQXAC9IVRw&res=PreMuxed","Add item to personal list","NOTE, this will create list if not created
name: Name of personal list
Works on GET and POST