private void button7_Click(object sender, EventArgs e) { if (list_startpage.SelectedItems.Count > 0) { SiteItemEntry entry = list_startpage.SelectedItems[0].Tag as SiteItemEntry; FormItemList dlg = new FormItemList(Youtube2MP.GetList(entry)); dlg.ShowDialog(); } }
public void AddItemToPlayList(GUIListItem pItem, ref PlayList playList, VideoInfo qa, bool check) { if (playList == null || pItem == null) { return; } if (pItem.MusicTag == null) { return; } string PlayblackUrl = ""; YouTubeEntry vid; LocalFileStruct file = pItem.MusicTag as LocalFileStruct; if (file != null) { Uri videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + file.VideoId); Video video = Youtube2MP.request.Retrieve <Video>(videoEntryUrl); vid = video.YouTubeEntry; } else { vid = pItem.MusicTag as YouTubeEntry; if (vid == null && check) { SiteItemEntry entry = pItem.MusicTag as SiteItemEntry; if (entry != null) { GenericListItemCollections genericListItem = Youtube2MP.GetList(entry); if (entry.Provider == "VideoItem" && genericListItem.Items.Count > 0) { vid = genericListItem.Items[0].Tag as YouTubeEntry; } } } if (vid != null && vid.Authors.Count == 0 && check) { Uri videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + Youtube2MP.GetVideoId(vid)); try { Video video = Youtube2MP.request.Retrieve <Video>(videoEntryUrl); vid = video.YouTubeEntry; } catch (Exception) { vid = null; } } } if (vid != null) { if (vid.Media.Contents.Count > 0) { PlayblackUrl = string.Format("http://www.youtube.com/v/{0}", Youtube2MP.getIDSimple(vid.Id.AbsoluteUri)); } else { PlayblackUrl = vid.AlternateUri.ToString(); } PlayListItem playlistItem = new PlayListItem(); playlistItem.Type = PlayListItem.PlayListItemType.VideoStream; // Playlists.PlayListItem.PlayListItemType.Audio; qa.Entry = vid; playlistItem.FileName = PlayblackUrl; playlistItem.Description = pItem.Label; if (vid.Duration != null && vid.Duration.Seconds != null) { playlistItem.Duration = Convert.ToInt32(vid.Duration.Seconds, 10); } playlistItem.MusicTag = qa; playList.Add(playlistItem); } }