Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,SongName,SoundCloudURL")] SoundCloud soundCloud)
        {
            if (id != soundCloud.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(soundCloud);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SoundCloudExists(soundCloud.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(soundCloud));
        }
Пример #2
0
 protected override void Run()
 {
     ServerVoiceConnections = new ConcurrentDictionary <ulong, VoiceConnection>();
     UserVoiceConnections   = new ConcurrentDictionary <ulong, AudioInStream>();
     AudioQueue             = new AudioQueue();
     AcaBoxTTS  = new AcaBoxTTS(Provider.GetService <HttpService>(), Provider.GetService <MathService>());
     SoundCloud = new SoundCloud(Provider.GetService <Config>().SoundCloudClientId, Provider.GetService <HttpService>());
     Youtube    = new YoutubeDownloader("youtube-dl", $"-f mp4 --playlist-end {Provider.GetService<Config>().YouTubePlaylistMaxItems.ToString()} --ignore-errors");
 }
Пример #3
0
 /// <summary>
 /// Convertit l'entrée de playlist minifiée en réelle entrée de playlist
 /// </summary>
 /// <param name="youtube_client"></param>
 /// <param name="soundcloud_client"></param>
 /// <returns></returns>
 public PlayListEntry expand(Youtube.Youtube youtube_client, SoundCloud.SoundCloud soundcloud_client)
 {
     PlayListEntry p = null;
     if (this.url.StartsWith("https://www.youtube.com") || this.url.StartsWith("https://m.youtube.com"))
         p = new PlayListEntry(youtube_client.resolveTrack(this.url), this.user, false);
     else if (this.url.StartsWith("https://soundcloud.com/") || this.url.StartsWith("https://m.soundcloud.com/"))
         p = new PlayListEntry(soundcloud_client.resolveTrack(this.url), this.user, false);
     return p;
 }
Пример #4
0
        public async Task <IActionResult> Create([Bind("ID,SongName,SoundCloudURL")] SoundCloud soundCloud)
        {
            if (ModelState.IsValid)
            {
                _context.Add(soundCloud);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(soundCloud));
        }
Пример #5
0
 /// <summary>
 /// Transforme une mini playlist en réelle playlist
 /// </summary>
 /// <param name="youtube_client"></param>
 /// <param name="soundcloud_client"></param>
 /// <returns></returns>
 public Playlist expand(Youtube.Youtube youtube_client, SoundCloud.SoundCloud soundcloud_client)
 {
     Playlist p = new Playlist();
     foreach (PlayListEntryMinified e in to_play)
     {
         p.to_play.Add(e.expand(youtube_client, soundcloud_client));
     }
     foreach (PlayListEntryMinified e in played)
     {
         p.played.Add(e.expand(youtube_client, soundcloud_client));
     }
     p.banned = this.banned;
     return p;
 }
Пример #6
0
        private static async Task <TimeSpan?> GetByNameAsync(Uri url, string youTubeKey = null, ITwitchCredentials twitchCredentials = null)
        {
            if (url == null)
            {
                throw new ArgumentNullException();
            }

            if (url.AbsolutePath.EndsWith(".mp4", StringComparison.InvariantCultureIgnoreCase))
            {
                // Assume MP4
                return(await MP4.GetDurationAsync(url));
            }
            else if (url.AbsolutePath.EndsWith(".m3u8", StringComparison.InvariantCultureIgnoreCase))
            {
                // Assume HLS
                return(await HLS.GetPlaylistDurationAsync(url));
            }
            else if (url.Authority.EndsWith("vimeo.com"))
            {
                return(await Vimeo.GetDurationAsync(url));
            }
            else if (url.Authority.EndsWith("youtube.com") || url.Authority.EndsWith("youtu.be"))
            {
                return(youTubeKey == null
                    ? null
                    : await new YouTube(youTubeKey).GetDurationAsync(url));
            }
            else if (url.Authority.EndsWith("dailymotion.com") || url.Authority.EndsWith("dai.ly"))
            {
                return(await Dailymotion.GetDurationAsync(url));
            }
            else if (url.Authority.EndsWith("twitch.tv"))
            {
                return(await new Twitch(twitchCredentials).GetDurationAsync(url));
            }
            else if (url.Authority.EndsWith("soundcloud.com"))
            {
                return(await SoundCloud.GetDurationAsync(url));
            }
            else
            {
                return(null);
            }
        }
Пример #7
0
 /// <summary>
 /// Transforme les messages présents dans la boite mail en entrées de playlist pour la lecture
 /// </summary>
 /// <param name="youtube_client">Instance du client youtube permettant d'interragir avec le service de vidéo en ligne</param>
 /// <param name="soundcloud_client">Instance du client soundcloud permettant d'interragir avec le service de son en ligne</param>
 /// <returns></returns>
 public List<Music.PlayListEntry> getPlaylistEntriesFromMail(Youtube.Youtube youtube_client, SoundCloud.SoundCloud soundcloud_client)
 {
     List<Music.PlayListEntry> res = new List<Music.PlayListEntry>();
     List<Gmail> msg = this.getMessages();
     foreach (Gmail g in msg)
     {
         Music.ITrack track = null;
         if (Youtube.Youtube.isCompatible(g.content))
             track = youtube_client.resolveTrack(g.content);
         else if (SoundCloud.SoundCloud.isCompatible(g.content))
             track = soundcloud_client.resolveTrack(g.content);
         if (track != null)
         {
             res.Add(new Music.PlayListEntry(track, g.user, false));
         }
     }
     return res;
 }
Пример #8
0
 /// <summary>
 /// Charge la playlist depuis un format JSON
 /// </summary>
 /// <param name="youtube_client">Client youtube</param>
 /// <param name="soundcloud_client">Client Soundcloud</param>
 public void load(Youtube.Youtube youtube_client, SoundCloud.SoundCloud soundcloud_client)
 {
     if (File.Exists("save.json") == false)
         return;
     string data = new StreamReader(File.OpenRead("save.json")).ReadToEnd();
     Playlist p = (JsonConvert.DeserializeObject<PlaylistMinified>(data)).expand(youtube_client, soundcloud_client);
     this.to_play = p.to_play;
     this.played = p.played;
     this.playing = p.playing;
     this.banned = p.banned;
 }
Пример #9
0
 public void Constructor_Throws_ArgumentNullException_When_The_ClientId_Is_Null()
 {
     var soundCloud = new SoundCloud((string)null);
 }
Пример #10
0
 protected override void AdditionalSetup()
 {
     const string clientId = "db840ada2477a93d5fdbcc96a46b37c1"; // Not my own, but some clientId I found on soundcloud
     SoundCloud = new SoundCloud(clientId);
 }