Exemplo n.º 1
0
        private void BuildChannel(string channelQuery)
        {
            //Get profile and create channel object
            try
            {
                YouTubeService service = new YouTubeService(_appName, _devKey);
                if (!Object.Equals(service, null))
                {
                    ProfileEntry profile = (ProfileEntry)service.Get(channelQuery);

                    if (!Object.Equals(profile, null))
                    {
                        _channel = new Channel(profile, _user, _userID);
                    }
                }
            }
            catch (GDataRequestException gdre)
            {
                using (var logClient = new BILoggerServiceClient())
                    logClient.HandleException(gdre.Message, "Query: " + channelQuery, Utility.ApplicationName, LogTypeEnum.Error, LogActionEnum.LogAndEmail, "ChannelManager.BuildChannel()", "Drone.API.YouTube Exception", string.Empty, string.Empty, System.Environment.MachineName);
            }
            catch (Exception e)
            {
                using (var logClient = new BILoggerServiceClient())
                    logClient.HandleBIException(e.ConvertToBIException(LogActionEnum.Log, LogTypeEnum.Error, "Drone.API.YouTube Exception", "ChannelManager.BuildChannel()", "nouser", System.Environment.MachineName, "Query: " + channelQuery));
            }
        }
Exemplo n.º 2
0
        public static bool YoutubeEntry2Song(string fileurl, ref Song song, ref YouTubeEntry en)
        {
            if (fileurl.Contains("youtube."))
            {
                String videoEntryUrl = "http://gdata.youtube.com/feeds/api/videos/" + getIDSimple(fileurl);
                en = (YouTubeEntry)service.Get(videoEntryUrl);
            }
            if (en == null)
            {
                return(false);
            }

            string title = en.Title.Text;

            if (title.Contains("-"))
            {
                song.Artist = title.Split('-')[0].Trim();
                song.Title  = title.Split('-')[1].Trim();
            }
            else
            {
                song.Artist = title;
            }

            song.FileName = fileurl;
            try
            {
                song.Duration = Convert.ToInt32(en.Duration.Seconds);
            }
            catch
            {
                song.Duration = 0;
            }
            song.Track       = 0;
            song.URL         = fileurl;
            song.TimesPlayed = 1;

            return(true);
        }