Finally add documentation

This commit is contained in:
Mike Nolan 2022-05-10 12:22:43 -05:00
parent 5538aa2e5e
commit 9a884bc763
15 changed files with 339 additions and 1 deletions

27
README.md Normal file
View File

@ -0,0 +1,27 @@
# Tesses.YouTubeDownloader
[Server Endpoints](docs/Server.md)
<br>
[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

View File

@ -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
});

View File

@ -330,6 +330,5 @@ namespace Tesses.YouTubeDownloader
public string Id { get; set; }
public string Title { get; set; }
public string Url { get; set; }
}
}

View File

@ -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);

11
docs/Bell.md Normal file
View File

@ -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|

12
docs/Configure.md Normal file
View File

@ -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 |

12
docs/JsonAndEnum.md Normal file
View File

@ -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) |

9
docs/QueueList.md Normal file
View File

@ -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)

10
docs/Resolution.md Normal file
View File

@ -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)

7
docs/SavedChannel.md Normal file
View File

@ -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 |

10
docs/SavedPlaylist.md Normal file
View File

@ -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[] |

16
docs/SavedVideo.md Normal file
View File

@ -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) |

20
docs/Server.md Normal file
View File

@ -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) |

7
docs/Subscription.md Normal file
View File

@ -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) |

11
docs/VideoProgress.md Normal file
View File

@ -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