Add project files.
This commit is contained in:
		
							
								
								
									
										69
									
								
								TomatenMusicCore/Music/Entitites/FullTrackContext.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								TomatenMusicCore/Music/Entitites/FullTrackContext.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,69 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Text; | ||||
| using System.Threading.Tasks; | ||||
| using TomatenMusic.Services; | ||||
| using System.Linq; | ||||
| using SpotifyAPI.Web; | ||||
| using Lavalink4NET.Player; | ||||
| using Microsoft.Extensions.DependencyInjection; | ||||
| using Lavalink4NET; | ||||
|  | ||||
| namespace TomatenMusic.Music.Entitites | ||||
| { | ||||
|     public class FullTrackContext | ||||
|     { | ||||
|         public bool IsFile { get; set; } | ||||
|         public string YoutubeDescription { get; set; } | ||||
|         public Uri YoutubeUri { get; set; } | ||||
|         public IEnumerable<string> YoutubeTags { get; set; } | ||||
|         public ulong YoutubeViews { get; set; } | ||||
|         public ulong YoutubeLikes { get; set; } | ||||
|         public Uri YoutubeThumbnail { get; set; } | ||||
|         public DateTime YoutubeUploadDate { get; set; } | ||||
|         // | ||||
|         // Summary: | ||||
|         //     Gets the author of the track. | ||||
|         public Uri YoutubeAuthorThumbnail { get; set; } | ||||
|         public ulong YoutubeAuthorSubs { get; set; } | ||||
|         public Uri YoutubeAuthorUri { get; set; } | ||||
|         public ulong? YoutubeCommentCount { get; set; } | ||||
|         public string SpotifyIdentifier { get; set; } | ||||
|         public SimpleAlbum SpotifyAlbum { get; set; } | ||||
|         public List<SimpleArtist> SpotifyArtists { get; set; } | ||||
|         public int SpotifyPopularity { get; set; } | ||||
|         public Uri SpotifyUri { get; set; } | ||||
|  | ||||
|         public static async Task<LavalinkTrack> PopulateAsync(LavalinkTrack track, string spotifyIdentifier = null) | ||||
|         { | ||||
|             FullTrackContext context = (FullTrackContext)track.Context; | ||||
|  | ||||
|             if (context == null) | ||||
|                 context = new FullTrackContext(); | ||||
|  | ||||
|             var spotifyService = TomatenMusicBot.ServiceProvider.GetRequiredService<ISpotifyService>(); | ||||
|             var youtubeService = TomatenMusicBot.ServiceProvider.GetRequiredService<YoutubeService>(); | ||||
|             context.SpotifyIdentifier = spotifyIdentifier; | ||||
|             context.YoutubeUri = new Uri($"https://youtu.be/{track.TrackIdentifier}"); | ||||
|             track.Context = context; | ||||
|             Console.WriteLine(context); | ||||
|             await youtubeService.PopulateTrackInfoAsync(track); | ||||
|             await spotifyService.PopulateTrackAsync(track); | ||||
|              | ||||
|             return track; | ||||
|         } | ||||
|  | ||||
|         public static async Task<IEnumerable<LavalinkTrack>> PopulateTracksAsync(IEnumerable<LavalinkTrack> tracks) | ||||
|         { | ||||
|             foreach (var trackItem in tracks) | ||||
|             { | ||||
|                 await PopulateAsync(trackItem); | ||||
|             } | ||||
|  | ||||
|             return tracks; | ||||
|         } | ||||
|  | ||||
|  | ||||
|          | ||||
|     } | ||||
| } | ||||
							
								
								
									
										34
									
								
								TomatenMusicCore/Music/Entitites/LavalinkPlaylist.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								TomatenMusicCore/Music/Entitites/LavalinkPlaylist.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,34 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Text; | ||||
| using System.Linq; | ||||
| using TomatenMusic.Util; | ||||
| using DSharpPlus.Entities; | ||||
| using Lavalink4NET.Player; | ||||
|  | ||||
| namespace TomatenMusic.Music.Entitites | ||||
| { | ||||
|     public interface LavalinkPlaylist | ||||
|     { | ||||
|         public string Name { get; } | ||||
|         public IEnumerable<LavalinkTrack> Tracks { get; } | ||||
|         public Uri Url { get; } | ||||
|         public string AuthorName { get; set; } | ||||
|         public Uri AuthorUri { get; set; } | ||||
|         public string Description { get; set; } | ||||
|         public string Identifier { get; } | ||||
|         public Uri AuthorThumbnail { get; set; } | ||||
|  | ||||
|         public TimeSpan GetLength() | ||||
|         { | ||||
|             TimeSpan timeSpan = TimeSpan.FromTicks(0); | ||||
|  | ||||
|             foreach (var track in Tracks) | ||||
|             { | ||||
|                 timeSpan = timeSpan.Add(track.Duration); | ||||
|             } | ||||
|  | ||||
|             return timeSpan; | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										29
									
								
								TomatenMusicCore/Music/Entitites/SpotifyPlaylist.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								TomatenMusicCore/Music/Entitites/SpotifyPlaylist.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,29 @@ | ||||
| using Lavalink4NET.Player; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Text; | ||||
|  | ||||
| namespace TomatenMusic.Music.Entitites | ||||
| { | ||||
|     public class SpotifyPlaylist : LavalinkPlaylist | ||||
|     { | ||||
|         public string Name { get; } | ||||
|         public IEnumerable<LavalinkTrack> Tracks { get; } | ||||
|         public Uri Url { get; set; } | ||||
|         public string AuthorName { get; set; } | ||||
|         public Uri AuthorUri { get; set; } | ||||
|         public string Description { get; set; } | ||||
|         public int Followers { get; set; } | ||||
|         public string Identifier { get; } | ||||
|         public Uri AuthorThumbnail { get; set; } | ||||
|  | ||||
|  | ||||
|         public SpotifyPlaylist(string name, string id, IEnumerable<LavalinkTrack> tracks, Uri uri) | ||||
|         { | ||||
|             Name = name; | ||||
|             Identifier = id; | ||||
|             Tracks = tracks; | ||||
|             Url = uri; | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										38
									
								
								TomatenMusicCore/Music/Entitites/YoutubePlaylist.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								TomatenMusicCore/Music/Entitites/YoutubePlaylist.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Text; | ||||
| using System.Linq; | ||||
| using Google.Apis.YouTube.v3.Data; | ||||
| using Lavalink4NET.Player; | ||||
|  | ||||
| namespace TomatenMusic.Music.Entitites | ||||
| { | ||||
|     public class YoutubePlaylist : LavalinkPlaylist | ||||
|     { | ||||
|         public string Name { get; } | ||||
|  | ||||
|         public IEnumerable<LavalinkTrack> Tracks { get; } | ||||
|  | ||||
|         public int TrackCount { get; } | ||||
|  | ||||
|         public Uri Url { get; } | ||||
|  | ||||
|         public string AuthorName { get; set; } | ||||
|         public Uri AuthorUri { get; set; } | ||||
|         public string Description { get; set; } | ||||
|         public Uri Thumbnail { get; set; } | ||||
|         public DateTime CreationTime { get; set; } | ||||
|         public string Identifier { get; } | ||||
|         public Playlist YoutubeItem { get; set; } | ||||
|         public Uri AuthorThumbnail { get; set; } | ||||
|  | ||||
|         public YoutubePlaylist(string name, IEnumerable<LavalinkTrack> tracks, Uri uri) | ||||
|         { | ||||
|             Identifier = uri.ToString().Replace("https://www.youtube.com/playlist?list=", ""); | ||||
|             Name = name; | ||||
|             Tracks = tracks; | ||||
|             Url = uri; | ||||
|             TrackCount = tracks.Count(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Tim Müller
					Tim Müller