/// <summary>
        /// Gets the specified stationid.
        /// </summary>
        /// <param name="stationid">The station id.</param>
        public void Get(string stationid)
        {
            var gr = new RadioTime();

            gr.Settings = Grabber.Settings;
            GuidId      = stationid;
            var url = string.Format("http://opml.radiotime.com/Describe.ashx?c=nowplaying&id={0}&{1}", GuidId,
                                    Grabber.Settings.GetParamString());

            gr.GetData(url, false, false);
            var line = 0;

            foreach (var outline in gr.Body)
            {
                if (outline.Key == "station")
                {
                    Image    = outline.Image;
                    Name     = outline.Text;
                    PresetId = outline.PresetId;
                    GuidId   = outline.GuidId;
                }

                if (outline.Key == "show")
                {
                    ShowImage   = string.Format("http://radiotime-logos.s3.amazonaws.com/{0}.png", GuidId);
                    Description = outline.Text;
                    var i = 0;
                    if (int.TryParse(outline.Duration, out i))
                    {
                        Duration = i;
                    }
                    i = 0;
                    if (int.TryParse(outline.Remain, out i))
                    {
                        Remains = i;
                    }
                }
                switch (line)
                {
                case 1:
                    Description = outline.Text;
                    break;

                case 2:
                    Location = outline.Text;
                    break;
                }
                line++;
            }

            if (string.IsNullOrEmpty(ShowImage))
            {
                ShowImage = Image;
            }
        }
예제 #2
0
        public string GetPresetFolder()
        {
            var tempGrabber = new RadioTime();
            tempGrabber.Settings = _setting;
            tempGrabber.GetData(_setting.PresetsUrl, false, Translation.Presets);

            var dlg = (GUIDialogMenu) GUIWindowManager.GetWindow((int) Window.WINDOW_DIALOG_MENU);
            if (dlg == null)
                return null;
            dlg.Reset();
            dlg.SetHeading(Translation.SelectPresetFolder);

            var canShow = false;
            foreach (var body in tempGrabber.Body)
            {
                if (body.Type == RadioTimeOutline.OutlineType.link)
                {
                    dlg.Add(body.Text);
                    canShow = true;
                }
            }

            if (canShow)
            {
                dlg.DoModal(GetID);
                if (dlg.SelectedId == -1)
                    return null;
                return tempGrabber.Body[dlg.SelectedId - 1].GuidId;
            }
            else
                return noPresetFolders;
        }
        /// <summary>
        /// Gets the specified stationid.
        /// </summary>
        /// <param name="stationid">The station id.</param>
        /// <param name="hassong">The station hass song or not</param>
        public void Get(string stationid, bool hassong)
        {
            var gr = new RadioTime();

            gr.Settings = Grabber.Settings;
            GuidId      = stationid;
            var url = string.Format("http://opml.radiotime.com/Describe.ashx?c=nowplaying&id={0}&{1}", GuidId, Grabber.Settings.GetParamString());

            gr.GetData(url, false, false);

            var line = 0;

            foreach (var outline in gr.Body)
            {
                if (outline.Key == "station")
                {
                    Image    = outline.Image;
                    Name     = outline.Text;
                    PresetId = outline.PresetId;
                    GuidId   = outline.GuidId;
                }

                if (outline.Key == "show")
                {
                    // ShowImage = string.Format("http://radiotime-logos.s3.amazonaws.com/{0}.png", GuidId);
                    ShowImage   = string.Format("http://cdn-radiotime-logos.tunein.com/{0}.png", GuidId);
                    Description = outline.Text;
                    IsShow      = true;
                    ShowGuidId  = outline.GuidId;

                    var i = 0;
                    if (int.TryParse(outline.Duration, out i))
                    {
                        Duration = i;
                    }
                    i = 0;
                    if (int.TryParse(outline.Remain, out i))
                    {
                        Remains = i;
                    }
                    continue;
                }

                switch (line)
                {
                case 1:     // if station has song then [Artists - Song] else [Description]
                    if (!hassong)
                    {
                        Description = (string.IsNullOrEmpty(Description) ? "" : " - ") + outline.Text;
                    }
                    break;

                case 2:     // if station has song then [Genre | Description] else if Show [Other] else [Location]
                    if (hassong)
                    {
                        // Description = outline.Text;
                        Description = string.Empty;
                    }
                    else
                    {
                        if (IsShow)   // !Show
                        {
                            Location = outline.Text;
                        }
                    }
                    break;

                case 3:     // if station has song then [Location]
                    if (hassong)
                    {
                        Location = outline.Text;
                    }
                    break;
                }
                line++;
            }

            if (string.IsNullOrEmpty(ShowImage))
            {
                ShowImage = Image;
            }
        }
        /// <summary>
        /// Gets the specified stationid.
        /// </summary>
        /// <param name="stationid">The station id.</param>
        /// <param name="hassong">The station hass song or not</param>
        public void Get(string stationid, bool hassong)
        {
            var gr = new RadioTime();
            gr.Settings = Grabber.Settings;
            GuidId = stationid;
            var url = string.Format("http://opml.radiotime.com/Describe.ashx?c=nowplaying&id={0}&{1}", GuidId, Grabber.Settings.GetParamString());
            gr.GetData(url, false, false);

            var line = 0;
            foreach (var outline in gr.Body)
            {
                if (outline.Key == "station")
                {
                    Image = outline.Image;
                    Name = outline.Text;
                    PresetId = outline.PresetId;
                    GuidId = outline.GuidId;
                }

                if (outline.Key == "show")
                {
                    // ShowImage = string.Format("http://radiotime-logos.s3.amazonaws.com/{0}.png", GuidId);
                    ShowImage = string.Format("http://cdn-radiotime-logos.tunein.com/{0}.png", GuidId);
                    Description = outline.Text;
                    IsShow = true;
                    ShowGuidId = outline.GuidId;

                    var i = 0;
                    if (int.TryParse(outline.Duration, out i))
                        Duration = i;
                    i = 0;
                    if (int.TryParse(outline.Remain, out i))
                        Remains = i;
                    continue;
                }

                switch (line)
                {
                    case 1: // if station has song then [Artists - Song] else [Description]
                        if (!hassong)
                        {
                          Description = (string.IsNullOrEmpty(Description) ? "" : " - ") + outline.Text;
                        }
                        break;
                    case 2: // if station has song then [Genre | Description] else if Show [Other] else [Location]
                        if (hassong)
                        {
                          // Description = outline.Text;
                          Description = string.Empty;
                        }
                        else
                        {
                          if (IsShow) // !Show
                          {
                            Location = outline.Text;
                          }
                        }
                        break;
                    case 3: // if station has song then [Location]
                        if (hassong)
                        {
                          Location = outline.Text;
                        }
                        break;
                }
                line++;
            }

            if (string.IsNullOrEmpty(ShowImage))
                ShowImage = Image;
        }
예제 #5
0
        /// <summary>
        /// Gets the specified stationid.
        /// </summary>
        /// <param name="stationid">The station id.</param>
        public void Get(string stationid)
        {
            RadioTime gr = new RadioTime();
              gr.Settings = Grabber.Settings;
              GuidId = stationid;
              string url = string.Format("http://opml.radiotime.com/Describe.ashx?c=nowplaying&id={0}&{1}", GuidId,
                                 Grabber.Settings.GetParamString());
              gr.GetData(url,false, false);
              int line = 0;
              foreach (RadioTimeOutline outline in gr.Body)
              {
            if (outline.Key == "station")
            {
              Image = outline.Image;
              Name = outline.Text;
              PresetId = outline.PresetId;
              GuidId = outline.GuidId;
            }

            if (outline.Key == "show")
            {
              ShowImage = string.Format("http://radiotime-logos.s3.amazonaws.com/{0}.png", GuidId);
              Description = outline.Text;
              int i = 0;
              if (int.TryParse(outline.Duration, out i))
            Duration = i;
              i = 0;
              if (int.TryParse(outline.Remain, out i))
            Remains = i;
            }
            switch (line)
            {
              case 1:
            Description = outline.Text;
            break;
              case 2:
            Location = outline.Text;
            break;
            }
            line++;
              }

              if (string.IsNullOrEmpty(ShowImage))
            ShowImage = Image;
        }
예제 #6
0
        /// <summary>
        /// Adds to favorites.
        /// </summary>
        /// <param name="p">The station id.</param>
        private void AddToFavorites(string presetid)
        {
            List<RadioTimeOutline> tempresets = new List<RadioTimeOutline>();

              string folderid = "";
              string selectedID = "";
              RadioTime tempGrabber = new RadioTime();
              tempGrabber.Settings = _setting;
              tempGrabber.GetData(_setting.PresetsUrl, false, false, Translation.Presets);

              int folderCount = 0;
              foreach (RadioTimeOutline body in tempGrabber.Body)
              {
            if (body.Type == RadioTimeOutline.OutlineType.link)
              folderCount++;
              }

              if (folderCount == 0) // only one preset folder (main) - plugin chooses first empty space to put preset
              {
            // first i have to fill the list with taken preset numbers
            List<int> takenPresets = new List<int>();
            foreach (RadioTimeOutline body in tempGrabber.Body)
            {
              if (!string.IsNullOrEmpty(body.PresetNumber))
            takenPresets.Add(body.PresetNumberAsInt);
            }

            int i = 1;
            while (takenPresets.Contains(i)) // find empty space
              i++;

            selectedID = i.ToString();
              }
              else // more folders - ask user
              {
            var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
            if (dlg == null)
              return;
            dlg.Reset();
            dlg.SetHeading(Translation.SelectPresetFolder);

            foreach (RadioTimeOutline body in tempGrabber.Body)
            {
              if (body.Type == RadioTimeOutline.OutlineType.link)
            dlg.Add(body.Text);
            }

            dlg.DoModal(GetID);
            if (dlg.SelectedId == -1)
              return;
            folderid = tempGrabber.Body[dlg.SelectedId - 1].GuidId;

            tempGrabber.GetData(tempGrabber.Body[dlg.SelectedId - 1].Url, false, false);

            // first i have to find out the largest preset number
            int biggestPresetNumber = 0;
            foreach (RadioTimeOutline body in tempGrabber.Body)
            {
              if (!string.IsNullOrEmpty(body.PresetNumber) && body.PresetNumberAsInt > biggestPresetNumber)
            biggestPresetNumber = body.PresetNumberAsInt;
            }

            // then i fill x number of presets
            for (int i = 0; i < (biggestPresetNumber + Settings.LOCAL_PRESETS_NUMBER); i++)
            {
              tempresets.Add(new RadioTimeOutline());
            }

            // then i fill the list with existing presets from the folder
            foreach (RadioTimeOutline body in tempGrabber.Body)
            {
              if (!string.IsNullOrEmpty(body.PresetNumber) && body.PresetNumberAsInt-1 < tempresets.Count)
              {
            tempresets[body.PresetNumberAsInt-1] = body;
              }
            }

            dlg.Reset();
            dlg.SetHeading(Translation.SelectPresetNumber);

            for (int i = 0; i < tempresets.Count; i++)
            {
              RadioTimeOutline outline = tempresets[i];
              if (string.IsNullOrEmpty(outline.Text))
            dlg.Add(string.Format("<{0}>", Translation.Empty));
              else
            dlg.Add(outline.Text);
            }

            dlg.DoModal(GetID);

            if (dlg.SelectedId == -1)
              return;

            selectedID = dlg.SelectedId.ToString();
              }

              try
              {
            grabber.AddPreset(presetid, folderid, selectedID);
            //UpdateList();
              }
              catch (Exception)
              {
            ErrMessage(Translation.ComunicationError);
              }
        }
예제 #7
0
 //// do the clicked action
 protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
 {
     ////
       //// look for button pressed
       ////
       //// record ?
       if (actionType == Action.ActionType.ACTION_RECORD)
       {
     //ExecuteRecord();
       }
       else if (control == btnSwitchView)
       {
     switch ((View)mapSettings.ViewAs)
     {
       case View.List:
     mapSettings.ViewAs = (int)View.Icons;
     break;
       case View.Icons:
     mapSettings.ViewAs = (int)View.BigIcons;
     break;
       case View.BigIcons:
     mapSettings.ViewAs = (int)View.List;
     break;
     }
     ShowPanel();
        // GUIControl.FocusControl(GetID, listControl.GetID);
       }
       else if (control == listControl)
       {
     // execute only for enter keys
     if (actionType == Action.ActionType.ACTION_SELECT_ITEM)
     {
       // station selected
       DoListSelection();
     }
       }
       else if (control == sortButton)
       {
     //sort button selected
     OnShowSortOptions();
     GUIControl.FocusControl(GetID, listControl.GetID);
       }
       else if (control == searchArtistButton)
       {
     DoSearchArtist();
     GUIControl.FocusControl(GetID, listControl.GetID);
       }
       else if (control == searchButton)
       {
     DoSearch();
     GUIControl.FocusControl(GetID, listControl.GetID);
       }
       else if (control == homeButton)
       {
     ShowPanel();
     DoHome();
     GUIControl.FocusControl(GetID, listControl.GetID);
       }
       else if (control == genresButton)
       {
     ShowPanel();
     DoGenres();
     GUIControl.FocusControl(GetID, listControl.GetID);
       }
       else if (control == presetsButton)
       {
     ShowPanel();
     DoPresets();
     GUIControl.FocusControl(GetID, listControl.GetID);
       }
       else if (control == nowPlayingButton)
       {
     GUIWindowManager.ActivateWindow(25652);
       }
       else if (control == localpresetsButton)
       {
     GUIWindowManager.ActivateWindow(25653);
       }
       else if (control == randomButton)
       {
     GUIControl.FocusControl(GetID, listControl.GetID);
     RadioTime gr = new RadioTime();
     gr.Settings = grabber.Settings;
     gr.GetData(grabber.CurentUrl + "&filter=random");
     if (gr.Body.Count == 1)
     {
       if (!string.IsNullOrEmpty(gr.Body[0].GuidId))
     DoPlay(gr.Body[0]);
       else if (!string.IsNullOrEmpty(gr.Body[0].Text))
     ErrMessage(gr.Body[0].Text);
     }
     else
       ErrMessage(Translation.NoStationsOrShowsAvailable);
       }
       base.OnClicked(controlId, control, actionType);
 }