コード例 #1
0
        void ProcessSongInfo(SongInfoResponseData songInfo)
        {
            string eventInfo = songInfo.requester != null ? "Requested by " + songInfo.requester.displayName : songInfo._event ?? "";
            string sources   = string.Join(", ", songInfo.song.sources.Select(s =>
            {
                if (!string.IsNullOrWhiteSpace(s.nameRomaji))
                {
                    return(s.nameRomaji);
                }
                return(s.name);
            }));
            string artists = string.Join(", ", songInfo.song.artists.Select(a =>
            {
                if (!string.IsNullOrWhiteSpace(a.nameRomaji))
                {
                    return(a.nameRomaji);
                }
                return(a.name);
            }));

            centerPanel.SetLabelText(songInfo.song.title, artists, sources, eventInfo, !string.IsNullOrWhiteSpace(eventInfo));

            if (User.LoggedIn)
            {
                SetFavouriteSprite(songInfo.song.favorite);
            }
            else
            {
                picFavourite.Visible = false;
            }
        }
コード例 #2
0
        private void menuItemCopySongInfo_Click(object sender, EventArgs e)
        {
            SongInfoResponseData info = songInfoStream.currentInfo;

            if (info != null)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(string.Join(", ", info.song.artists.Select(a => {
                    if (!string.IsNullOrWhiteSpace(a.nameRomaji))
                    {
                        return(a.nameRomaji);
                    }
                    return(a.name);
                })) + " - " + info.song.title + (info.song.sources.Length != 0 ? " [" + string.Join(", ", info.song.sources.Select(s =>
                {
                    if (!string.IsNullOrWhiteSpace(s.nameRomaji))
                    {
                        return(s.nameRomaji);
                    }
                    return(s.name);
                }))
                                                 + "]" : ""));
                Clipboard.SetText(sb.ToString());
            }
        }
コード例 #3
0
        private void menuItemCopySongInfo_Click(object sender, EventArgs e)
        {
            SongInfoResponseData info = songInfoStream.currentInfo;
            var sb = new StringBuilder();

            sb.AppendLine(info.song.title);
            sb.AppendLine(String.Join(", ", info.song.artists.Select(a => a.name ?? a.nameRomaji)));
            sb.AppendLine(String.Join(", ", info.song.sources.Select(s => s.name ?? s.nameRomaji)));
            Clipboard.SetText(sb.ToString());
        }
コード例 #4
0
        private void coverImage_Click(object sender, EventArgs e)
        {
            SongInfoResponseData info = songInfoStream.currentInfo;

            if (info != null)
            {
                if (info.song.albums.Length != 0)
                {
                    Process.Start(MUSIC_LINK + songInfoStream.currentInfo.song.albums[0].id);
                }
            }
        }
コード例 #5
0
ファイル: SongInfo.cs プロジェクト: MiincK/windows-app
        private void ParseSongInfo(string data)
        {
            string noWhitespaceData = new string(data.Where(c => !Char.IsWhiteSpace(c)).ToArray());

            if (noWhitespaceData.Contains("\"op\":0"))
            {
                //Identify/Welcome response
                WelcomeResponse resp = JsonConvert.DeserializeObject <WelcomeResponse>(data);
                ProcessWelcomeResponse(resp);
            }
            else if (noWhitespaceData.Contains("\"op\":1"))
            {
                //Song info
                SongInfoResponse resp = JsonConvert.DeserializeObject <SongInfoResponse>(data);
                if (resp.t != "TRACK_UPDATE")
                {
                    return;
                }

                currentInfo = resp.d;
                currentInfo.song.sources = currentInfo.song.sources ?? new Source[0];
                foreach (var source in currentInfo.song.sources)
                {
                    source.name       = Clean(source.name);
                    source.nameRomaji = Clean(source.nameRomaji);
                }

                foreach (var artist in currentInfo.song.artists)
                {
                    artist.name       = Clean(artist.name);
                    artist.nameRomaji = Clean(artist.nameRomaji);
                }
                currentInfo.song.title = Clean(currentInfo.song.title);

                if (currentInfo.requester != null)
                {
                    currentInfo.requester.displayName = Clean(currentInfo.requester.displayName);
                    currentInfo.requester.username    = Clean(currentInfo.requester.username);
                }

                if (currentInfo._event != null)
                {
                    currentInfo._event = Clean(currentInfo._event);
                }

                factory.StartNew(() =>
                {
                    OnSongInfoReceived(currentInfo);
                });
            }
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: gatoko666/windows-app
        void ProcessSongInfo(SongInfoResponseData songInfo)
        {
            string eventInfo = songInfo.requester != null ? "Requested by " + songInfo.requester.displayName : songInfo._event ?? "";
            string source    = songInfo.song.source.Length > 0 ? songInfo.song.source[0].name : "";

            centerPanel.SetLabelText(songInfo.song.title, string.Join(",", songInfo.song.artists.Select(a => a.name)), source, eventInfo, !string.IsNullOrWhiteSpace(eventInfo));

            if (User.LoggedIn)
            {
                SetFavouriteSprite(songInfo.song.favorite);
            }
            else
            {
                picFavourite.Visible = false;
            }
        }
コード例 #7
0
        void ProcessSongInfo(SongInfoResponseData songInfo)
        {
            string eventInfo = songInfo.requester != null?string.Format(Localisation.Current.mReqestedBy, songInfo.requester.displayName) : songInfo._event ?? "";

            string source = songInfo.song.sources.Length > 0 ? String.Join(", ", songInfo.song.sources.Select(x => x.name ?? x.nameRomaji)) : "";

            if (!string.IsNullOrWhiteSpace(source))
            {
                eventInfo = source + (String.IsNullOrWhiteSpace(eventInfo)? "" : "; " + eventInfo);
            }
            centerPanel.SetLabelText(songInfo.song.title,
                                     string.Join(", ", songInfo.song.artists.Select(a => a.name ?? a.nameRomaji)),
                                     eventInfo);
            if (User.LoggedIn)
            {
                SetFavouriteSprite(songInfo.song.favorite);
            }
            else
            {
                picFavourite.Visible = false;
            }
        }
コード例 #8
0
        void ProcessSongInfo(SongInfoResponseData songInfo)
        {
            string eventInfo = songInfo.requester != null ? "Requested by " + songInfo.requester.displayName : songInfo._event?.name ?? "";
            string sources   = string.Join(", ", songInfo.song.sources.Select(s =>
            {
                if (!string.IsNullOrWhiteSpace(s.nameRomaji))
                {
                    return(s.nameRomaji);
                }
                return(s.name);
            }));
            string artists = string.Join(", ", songInfo.song.artists.Select(a =>
            {
                if (!string.IsNullOrWhiteSpace(a.nameRomaji))
                {
                    return(a.nameRomaji);
                }
                return(a.name);
            }));

            centerPanel.SetLabelText(songInfo.song.title, artists, sources, eventInfo, !string.IsNullOrWhiteSpace(eventInfo));

            StreamType type = Settings.Get <StreamType>(Setting.StreamType);

            presence.Details               = songInfo.song.title.Length >= 50 ? songInfo.song.title.Substring(0, 50) : songInfo.song.title;
            presence.State                 = artists.Length >= 50 ? "by " + artists.Substring(0, 50) : "by " + artists;
            presence.Timestamps.Start      = DateTime.UtcNow;
            presence.Timestamps.End        = songInfo.startTime.AddMilliseconds(songInfo.song.duration * 1000);
            presence.Assets.LargeImageText = type == StreamType.Jpop ? "LISTEN.moe - JPOP" : "LISTEN.moe - KPOP";
            if (songInfo._event != null)
            {
                presence.Assets.LargeImageKey = Convert.ToBoolean(songInfo._event.presence) ? songInfo._event.presence : type == StreamType.Jpop ? "jpop" : "kpop";
            }
            else
            {
                presence.Assets.LargeImageKey = type == StreamType.Jpop ? "jpop" : "kpop";
            }

            if (songInfo.song.albums.Length != 0 && songInfo.song.albums[0].image != null)
            {
                coverImage.Load(CDN_COVER + songInfo.song.albums[0].image);
                coverImage.Visible = true;
            }
            else if (songInfo.song.albums.Length != 0)
            {
                coverImage.Load(CDN_COVER_NULL);
                coverImage.Visible = true;
            }
            else
            {
                coverImage.Visible = false;
            }

            if (User.LoggedIn)
            {
                SetFavouriteSprite(songInfo.song.favorite);
                centerPanel_Resize(null, null);
            }
            else
            {
                picFavourite.Visible = false;
            }

            if (Settings.Get <bool>(Setting.DiscordPresence))
            {
                client.SetPresence(presence);
                client.Invoke();
            }
        }