From 9a884bc7632e9bb3c80dacd5452e651931c14b98 Mon Sep 17 00:00:00 2001 From: Mike Nolan Date: Tue, 10 May 2022 12:22:43 -0500 Subject: [PATCH] Finally add documentation --- README.md | 27 +++ .../JavaScript/readme.txt | 183 ++++++++++++++++++ Tesses.YouTubeDownloader/SavedVideo.cs | 1 - Tesses.YouTubeDownloader/SubscribedTo.cs | 4 + docs/Bell.md | 11 ++ docs/Configure.md | 12 ++ docs/JsonAndEnum.md | 12 ++ docs/QueueList.md | 9 + docs/Resolution.md | 10 + docs/SavedChannel.md | 7 + docs/SavedPlaylist.md | 10 + docs/SavedVideo.md | 16 ++ docs/Server.md | 20 ++ docs/Subscription.md | 7 + docs/VideoProgress.md | 11 ++ 15 files changed, 339 insertions(+), 1 deletion(-) create mode 100644 README.md create mode 100644 Tesses.YouTubeDownloader.OtherClients/JavaScript/readme.txt create mode 100644 docs/Bell.md create mode 100644 docs/Configure.md create mode 100644 docs/JsonAndEnum.md create mode 100644 docs/QueueList.md create mode 100644 docs/Resolution.md create mode 100644 docs/SavedChannel.md create mode 100644 docs/SavedPlaylist.md create mode 100644 docs/SavedVideo.md create mode 100644 docs/Server.md create mode 100644 docs/Subscription.md create mode 100644 docs/VideoProgress.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..78b7d76 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# Tesses.YouTubeDownloader + +[Server Endpoints](docs/Server.md) +
+[Classes and Enums](docs/JsonAndEnum.md) + +# What this is known to work on + - Modern Linux/Windows/Mac (or any thing that can run .NET Standard 2.0+) + - Works on my Wii with [wii-linux-ngx](https://www.github.com/neagix/wii-linux-ngx) and [this guide](https://tesses.net/apps/tytd/2022/wii.php) (if it 404s its not complete yet) + +# To Use It as a server + using Tesses.YouTubeDownloader.Server; + using Tesses.YouTubeDownloader; + ... + TYTDCurrentDirectory currentDirectory=new TYTDCurrentDirectory(new HttpClient()); + TYTDServer server=new TYTDServer(currentDirectory); + server.RootServer.Server=new StaticServer("WebSite"); + HttpServerListener listener=new HttpServerListener(new System.Net.IPEndPoint(System.Net.IPAddress.Any,3252),server.InnerServer); + currentDirectory.StartLoop(); + TYTDStorage.FFmpeg ="/usr/bin/ffmpeg"; + Console.WriteLine("Almost Ready to Listen"); + await listener.ListenAsync(CancellationToken.None); + +Then: + + dotnet add package Tesses.YouTubeDownloader.Server + diff --git a/Tesses.YouTubeDownloader.OtherClients/JavaScript/readme.txt b/Tesses.YouTubeDownloader.OtherClients/JavaScript/readme.txt new file mode 100644 index 0000000..2fdb6d0 --- /dev/null +++ b/Tesses.YouTubeDownloader.OtherClients/JavaScript/readme.txt @@ -0,0 +1,183 @@ +To use this tytd for javascript + +=====models and enums===== +subscription: + Id: ChannelId + BellInfo: see subscription-conf + +subscriptions: + array of subscription + +resolutions: + 0: Mux + 1: PreMuxed + 2: AudioOnly + 3: VideoOnly + +subscription-conf: + DoNothing + GetInfo + Notify + Download + NotifyAndDownload (This is default) + +queuelist: + an array containing + Item1: see savedvideo + Item2: see resolutions + +savedvideoprogress: + Progress: progress as 0-100 + ProgressRaw: progress as 0.0-1.0 + Length: this is the length of video in bytes (Is wrong for Mux) + Video: see saved video + +savedvideo: + Id: Video Id + Title: Video Title + AuthorChannelId: YouTube Channel Id for Video + AuthorChannelTitle: YouTube Channel Title for Video + Description: Video Description + Keywords: YouTube Tags (this is an array) + Likes: YouTube Video Likes + Dislikes: YouTube Video Dislikes (I know they removed the ability but this can be used with return youtube dislikes) + Views: YouTube Views + Duration: Video Duration expressed as "00:03:48" could be "00:03:48.420420" + UploadDate: Video Upload Date expressed as "2015-07-22T19:00:00-05:00" + AddDate: date when added to downloader expressed as "2022-04-30T02:10:22.4359564-05:00" + +savedplaylist: + Id: Playlist Id + Title: Playlist Title + AuthorChannelId: YouTube Channel Id for Playlist + AuthorChannelTitle: YouTube Channel Title for Playlist + Description: Playlist Description + Videos: an array of Video Ids (the videos in the playlist) + +savedchannel: + Id: Channel Id + Title: Channel Title + + +=====methods===== + +constructor example: + + var tytd=new TYTD("http://192.168.0.142:3252/",1); + + +to download a video, playlist, channel or user: + + tytd.downloadItem("https://youtube.com/watch?v=il9nqWw9W3Y"); + tytd.downloadItem("https://youtube.com/watch?v=il9nqWw9W3Y",0); //for Mux + +to get video progress: + + tytd.progress(function(e){ + //see savedvideoprogress + }); + +to get queue: + tytd.queuelist(function(e){ + //see queuelist + }); + +to get videos: + tytd.getvideos(function(e){ + //this will be fired for each video + //see savedvideo + //to get title + e.Title + }); + +to get playlists: + tytd.getplaylists(function(e){ + //this will be fired for each playlist + //see savedplaylist + //to get title + e.Title + }); + +to get channels: + tytd.getchannels(function(e){ + //this will be fired for each channel + //see savedchannel + //to get title + e.Title + }); + +to get video info for id: + tytd.getvideoinfo("il9nqWw9W3Y",function(e){ + //see savedvideo + //to get title + e.Title //should be "Demi Lovato - Cool For The Summer (Official Video)" for this specific id + }); + +to get playlist info for id: + tytd.getplaylistinfo("PLa1F2ddGya_-UvuAqHAksYnB0qL9yWDO6",function(e) + { + e.Title //should be "Blender Fundamentals 2.8" for this specific id + }); + +to get channel info for id: + tytd.getchannelinfo("UCnyB9MYKRkSFK3IIB32CoVw",function(e) + { + e.Title //should be "DemiLovatoVEVO" for this specific id + }); + +to get subscriptions: + tytd.getsubscriptions(function(e){ + //see subscriptions + }); + +to subscribe (ChannelId): + You Can replace NotifyAndDownload with anything from subscription-conf + + if you want to get info about channel: + tytd.subscribe("UCnyB9MYKRkSFK3IIB32CoVw",true,"NotifyAndDownload"); + if you dont want to get info about channel: + tytd.subscribe("UCnyB9MYKRkSFK3IIB32CoVw",false,"NotifyAndDownload"); + +to subscribe (username): + You Can replace NotifyAndDownload with anything from subscription-conf + + tytd.subscribe("DemiLovatoVEVO","NotifyAndDownload"); + +to unsubscribe: + tytd.unsubscribe("UCnyB9MYKRkSFK3IIB32CoVw"); + +to change bell (subscription-conf): + You Can replace Download with anything from subscription-conf + tytd.resubscribe("UCnyB9MYKRkSFK3IIB32CoVw","Download"); + +to enumerate directories: + tytd.getdirectories("SomeDir/SomeSubDir",function(e) + { + //if the path was "SomeDir/SomeSubDir/john" + //it would be "john" + //this is an array + }); + +to enumerate files: + tytd.getfiles("SomeDir/SomeSubDir",function(e) + { + //if the path was "SomeDir/SomeSubDir/john.txt" + //it would be "john.txt" + //this is an array + }); + +file exists: + fileexists("SomeFile.txt",function(){ + //SomeFile.txt exists + },function(){ + //SomeFile.txt doesnt exist + }); + +directory exists: + directoryexists("SomeDir",function(){ + //SomeDir exists + },function(){ + //SomeDir doesnt exist + }); + + diff --git a/Tesses.YouTubeDownloader/SavedVideo.cs b/Tesses.YouTubeDownloader/SavedVideo.cs index 0d9947b..1768942 100644 --- a/Tesses.YouTubeDownloader/SavedVideo.cs +++ b/Tesses.YouTubeDownloader/SavedVideo.cs @@ -330,6 +330,5 @@ namespace Tesses.YouTubeDownloader public string Id { get; set; } public string Title { get; set; } - public string Url { get; set; } } } \ No newline at end of file diff --git a/Tesses.YouTubeDownloader/SubscribedTo.cs b/Tesses.YouTubeDownloader/SubscribedTo.cs index d9c360d..9ede906 100644 --- a/Tesses.YouTubeDownloader/SubscribedTo.cs +++ b/Tesses.YouTubeDownloader/SubscribedTo.cs @@ -208,6 +208,10 @@ namespace Tesses.YouTubeDownloader { if(item2.Name == "yt:videoId") { + if(BellInfo.HasFlag(ChannelBellInfo.GetInfo)) + { + await Base.AddVideoAsync(item2.InnerText,Resolution.NoDownload); + } if(BellInfo.HasFlag(ChannelBellInfo.Download)) { await Base.AddVideoAsync(item2.InnerText); diff --git a/docs/Bell.md b/docs/Bell.md new file mode 100644 index 0000000..41f52af --- /dev/null +++ b/docs/Bell.md @@ -0,0 +1,11 @@ +# Bell + +This is an Enum + +| Name | Number | Description | +| ---- | ---- | --------------| +| DoNothing | 0 | Disable Bell| +| GetInfo | 1 | Get info about video only (different from getinfo arg on requests (that is for getting channel info)) | +| Notify | 2 | Notify (Calls Bell event in TYTDStorage abstract class) | +| Download | 3 | Download Video | +| NotifyAndDownload | 5 | Does the same as both Notify And Download| \ No newline at end of file diff --git a/docs/Configure.md b/docs/Configure.md new file mode 100644 index 0000000..11aa83a --- /dev/null +++ b/docs/Configure.md @@ -0,0 +1,12 @@ +# Configuration +This is Json Object (With these Key/Value Pairs) +File path is config/tytdprop.json +| Name | Description | Type | +| ------- | ----------------- | ----- | +| AlwaysDownloadChannel | Always download channel info when downloading Video or Playlist | Boolean | +| SubscriptionInterval | Time Between checking subscriptions ex "01:00:00" | TimeSpan (String) | +| UseLogs | Whether Downloader Logs errors or video downloads | Boolean | +| PrintVideoIds | Whether to print Download: Title with Id: to stdout | Boolean | +| PrintErrors | Whether to print exceptions | Boolean | +| LogVideoIds | Whether to log video Ids | Boolean | +| AddDateInLog | Whether to add Date in log | Boolean | diff --git a/docs/JsonAndEnum.md b/docs/JsonAndEnum.md new file mode 100644 index 0000000..626a8d1 --- /dev/null +++ b/docs/JsonAndEnum.md @@ -0,0 +1,12 @@ +# Classes and Enums +| Name | Description | Type | Structure | +| ------- | ----------------- | ----- | --- | +| SavedVideo | VideoInfo | Class | [View](SavedVideo.md) | +| SavedPlaylist | PlaylistInfo | Class | [View](SavedPlaylist.md) | +| SavedChannel | ChannelInfo | Class | [View](SavedChannel.md) | +| VideoProgress | Progress | Class | [View](VideoProgress.md) | +| Subscription | Subscription Info | Class | [View](Subscription.md) | +| Configure | App Configuration | Class | [View](Configure.md) | +| QueueList | Video Queue | List of Class | [View](QueueList.md) | +| Bell | Bell Setting (simular to on YouTube) | Enum | [View](Bell.md) | +| Resolution | Video Resolution | Enum | [View](Resolution.md) | \ No newline at end of file diff --git a/docs/QueueList.md b/docs/QueueList.md new file mode 100644 index 0000000..d118b94 --- /dev/null +++ b/docs/QueueList.md @@ -0,0 +1,9 @@ +# Queue List + +The Url is http://localhost:3252/api/v2/Progress + +This is Json Array (With This Object (Key/Value Pairs)) +| Name | Description | Type | +| ------- | ----------------- | ----- | +| Item1 | See [SavedVideo](SavedVideo.md) | Object | +| Item2 | See [Video Resolution](Resolution.md) | Resolution (Int32) diff --git a/docs/Resolution.md b/docs/Resolution.md new file mode 100644 index 0000000..9131d01 --- /dev/null +++ b/docs/Resolution.md @@ -0,0 +1,10 @@ +# Resolution + +This is an Enum + +| Name | Number| Used to be | +| ---- | ---- | -----| +| Mux | 0 | Converted | +| PreMuxed | 1 | NotConverted | +| AudioOnly | 2 | Audio | +| VideoOnly | 3 | N/A (Stored in "Converted" Directory) \ No newline at end of file diff --git a/docs/SavedChannel.md b/docs/SavedChannel.md new file mode 100644 index 0000000..62b9706 --- /dev/null +++ b/docs/SavedChannel.md @@ -0,0 +1,7 @@ +# Saved Channel +This is Json Object (With these Key/Value Pairs) +File Path is Channel/{Id}.json +| Name | Description | Type | +|--------|-------|------| +| Id | Channel Id | String +| Title | Channel Title | String | diff --git a/docs/SavedPlaylist.md b/docs/SavedPlaylist.md new file mode 100644 index 0000000..3dfb49f --- /dev/null +++ b/docs/SavedPlaylist.md @@ -0,0 +1,10 @@ +# Saved Playlist +This is Json Object (With these Key/Value Pairs) +File Path is Playlist/{Id}.json +| Name | Description | Type | +|--------|-------|------| +| Id | Playlist Id | String +| Title | Playlist Title | String | +| AuthorChannelId | YouTube Channel Id | String | +| AuthorChannelTitle | YouTube Channel Title | String | +| Videos | Videos in Playlist | String[] | \ No newline at end of file diff --git a/docs/SavedVideo.md b/docs/SavedVideo.md new file mode 100644 index 0000000..83d638c --- /dev/null +++ b/docs/SavedVideo.md @@ -0,0 +1,16 @@ +# Saved Video +This is Json Object (With these Key/Value Pairs) +File Path is Info/{Id}.json +| Name | Description | Type | +|--------|-------|------| +| Id | Video Id | String +| Title | Video Title | String | +| AuthorChannelId | YouTube Channel Id | String | +| AuthorChannelTitle | YouTube Channel Title | String | +| Keywords | YouTube Tags | String[] | +| Likes | Video Likes | Int64 | +| Dislikes | Video Dislikes | Int64 | +| Views | Video Views | Int64 | +| Duration | Video Duration ex 00:00:42 | TimeSpan (String) | +| UploadDate | Video Upload Date ex 2015-07-22T19:00:00-05:00 | DateTime (String) | +| AddDate | Date when added to downloader ex 2022-04-30T02:10:22.4359564-05:00 | DateTime (String) | diff --git a/docs/Server.md b/docs/Server.md new file mode 100644 index 0000000..1cf8194 --- /dev/null +++ b/docs/Server.md @@ -0,0 +1,20 @@ +# Server + +Get Requests + +| Url | Description | +|--------|-------| +| http://localhost:3252/api/v2/Progress | [Video Progress](VideoProgress.md) | +| http://localhost:3252/api/v2/QueueList | [Queue List](QueueList.md) | +| http://localhost:3252/api/AddItem/{UrlOrId} | Download Video, Playlist, Channel or UserName v1 (Same as http://localhost:3252/api/AddItemRes/1/{UrlOrId}) (this is valid on previous downloader) (I prefer this one) | +| http://localhost:3252/api/AddItemRes/{Resolution}/{UrlOrId} | Download Video, Playlist, Channel or UserName using [Resolution](Resolution.md) (uses the number) v1 (this is valid on previous downloader) (I prefer this one) | +| http://localhost:3252/api/v2/AddVideo?v={Id}&res=PreMuxed | Download Video v2 using [Resolution](Resolution.md) (uses the Name on queryparm res) (I Prefer v1) | +| http://localhost:3252/api/v2/AddPlaylist?v={Id}&res=PreMuxed | Download Playlist v2 using [Resolution](Resolution.md) (uses the Name on queryparm res) (I Prefer v1) | +| http://localhost:3252/api/v2/AddChannel?v={Id}&res=PreMuxed | Download Channel v2 using [Resolution](Resolution.md) (uses the Name on queryparm res) (I Prefer v1) | +| http://localhost:3252/api/v2/AddUser?v={Id}&res=PreMuxed | Download User v2 using [Resolution](Resolution.md) (uses the Name on queryparm res) (I Prefer v1) | +| http://localhost:3252/api/v2/AddItem?v={Id}&res=PreMuxed | Download Video, Playlist Channel or User v2 using [Resolution](Resolution.md) (uses the Name on queryparm res) (I Prefer v1) | +| http://localhost:3252/api/v2/subscribe?id={ChannelId}&getinfo=true\|false&conf=NotifyAndDownload | Subscribe to YouTuber (ChannelId), See [Bell](Bell.md) for conf queryparm | +| http://localhost:3252/api/v2/subscribe?id={UserName}&conf=NotifyAndDownload | Subscribe to YouTuber (UserName), See [Bell](Bell.md) for conf queryparm | +| http://localhost:3252/api/v2/resubscribe?id={ChannelId}&conf=Download | Change Bell for YouTuber, See [Bell](Bell.md) for conf queryparm | +| http://localhost:3252/api/v2/unsubscribe?id={ChannelId} | Unsubscribe from YouTuber | +| http://localhost:3252/api/v2/subscriptions | Get Subscriptions, Is a json array of [Subscription](Subscription.md) | \ No newline at end of file diff --git a/docs/Subscription.md b/docs/Subscription.md new file mode 100644 index 0000000..e9052ed --- /dev/null +++ b/docs/Subscription.md @@ -0,0 +1,7 @@ +# Subscription + +This is Json Object (With these Key/Value Pairs) +| Name | Description | Type | +|--------|-------|------| +| Id | Channel Id | String | +| BellInfo | See [Bell](Bell.md) | Bell (Int32) | \ No newline at end of file diff --git a/docs/VideoProgress.md b/docs/VideoProgress.md new file mode 100644 index 0000000..204b0e2 --- /dev/null +++ b/docs/VideoProgress.md @@ -0,0 +1,11 @@ +# Video Progress + +The Url is http://localhost:3252/api/v2/Progress + +This is Json Object (With these Key/Value Pairs) +| Name | Description | Type | +|--------|-------|------| +| Video | See [SavedVideo](SavedVideo.md) | Object | +| Progress | Video Progress (0-100) | Int32 +| ProgressRaw | Video Progress (0.0-1.0) | Double | +| Length | Video Length in bytes (Wrong for Mux) | Int64 \ No newline at end of file