Ejemplo n.º 1
0
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            res.FolderType = 1;
            string url = string.Format("http://gdata.youtube.com/feeds/api/playlists/{0}", entry.GetValue("id"));

            if (!string.IsNullOrEmpty(entry.GetValue("url")))
            {
                url = entry.GetValue("url");
            }
            YouTubeQuery query = new YouTubeQuery(url);

            query.NumberToRetrieve = 50;
            do
            {
                YouTubeFeed videos = Youtube2MP.service.Query(query);
                res.Title = videos.Title.Text;
                foreach (YouTubeEntry youTubeEntry in videos.Entries)
                {
                    res.Items.Add(Youtube2MP.YouTubeEntry2ListItem(youTubeEntry));
                }
                query.StartIndex += 50;
                if (videos.TotalResults < query.StartIndex + 50)
                {
                    break;
                }
            } while (true);
            res.ItemType = ItemType.Video;
            return(res);
        }
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();
              res.Title = entry.Title;
              int count = 0;
              int ii = 0;
              int.TryParse(entry.GetValue("items"), out ii);

              for (int i = Youtube2MP._settings.SearchHistory.Count; i > 0; i--)
              {
            count++;
            SiteItemEntry newentry = new SiteItemEntry();
            SearchVideo searchVideo = new SearchVideo();
            newentry.Provider = searchVideo.Name;
            newentry.SetValue("term", Youtube2MP._settings.SearchHistory[i - 1]);
            GenericListItem listItem = new GenericListItem()
                                     {
                                       Title = "Search result for :" + Youtube2MP._settings.SearchHistory[i - 1],
                                       IsFolder = true,
                                       //LogoUrl = YoutubeGUIBase.GetBestUrl(youTubeEntry.Media.Thumbnails),
                                       Tag = newentry
                                     };
            res.Items.Add(listItem);
            if (count > ii)
              break;
              }
              return res;
        }
 public GenericListItemCollections GetList(SiteItemEntry entry)
 {
     GenericListItemCollections res = new GenericListItemCollections();
       res.Title = entry.Title;
       res.Add(VevoFavorite());
       res.Add(VevoUploads());
       List<ArtistItem> artists = ArtistManager.Instance.GetVevoArtists();
       foreach (ArtistItem artistItem in artists)
       {
     UserVideos userVideos = new UserVideos();
     SiteItemEntry itemEntry = new SiteItemEntry();
     itemEntry.Provider = userVideos.Name;
     itemEntry.SetValue("id", artistItem.User);
     string title = artistItem.Name;
     GenericListItem listItem = new GenericListItem()
     {
       Title = title,
       IsFolder = false,
       LogoUrl = artistItem.Img_url,
       DefaultImage = "defaultArtistBig.png",
       Tag = itemEntry
     };
     res.Add(listItem);
       }
       res.ItemType = ItemType.Artist;
       return res;
 }
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            res.Title = "Downloaded Videos";
            foreach (LocalFileStruct localFileStruct in Youtube2MP._settings.LocalFile.Items)
            {
                GenericListItem listItem = new GenericListItem()
                {
                    Title    = localFileStruct.Title,
                    IsFolder = false,
                    LogoUrl  = "",
                    Tag      = localFileStruct,
                    Title2   =
                        File.Exists(localFileStruct.LocalFile)
                                           ? (new FileInfo(localFileStruct.LocalFile).Length / 1024 / 1024).ToString("0") + " MB"
                                           : "",
                    DefaultImage =
                        Path.GetDirectoryName(localFileStruct.LocalFile) + "\\" +
                        Path.GetFileNameWithoutExtension(localFileStruct.LocalFile) + ".png"
                        //ParentTag = artistItem
                };
                res.Items.Add(listItem);
            }
            res.ItemType = ItemType.Video;
            return(res);
        }
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            res.Title = entry.Title;
            Country country = new Country(entry.GetValue("country"), Youtube2MP.LastFmProfile.Session);

            TopTrack[] tracks = country.GetTopTracks();
            foreach (TopTrack topTrack in tracks)
            {
                SiteItemEntry newentry  = new SiteItemEntry();
                VideoItem     videoItem = new VideoItem();
                newentry.Provider = videoItem.Name;
                newentry.Title    = topTrack.Item.ToString();
                res.Items.Add(new GenericListItem()
                {
                    IsFolder     = false,
                    Title        = newentry.Title,
                    Tag          = newentry,
                    LogoUrl      = ArtistManager.Instance.GetArtistsImgUrl(topTrack.Item.Artist.Name),
                    DefaultImage = "defaultArtistBig.png"
                });
            }
            res.ItemType = ItemType.Video;
            return(res);
        }
        public GenericListItemCollections HomeGetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

              string feedUrl = "http://gdata.youtube.com/feeds/api/users/"+entry.GetValue("id");
              ProfileEntry profile = (ProfileEntry)Youtube2MP.service.Get(feedUrl);

              string img = "";
              try
              {
            foreach (IExtensionElementFactory factory in profile.ExtensionElements)
            {
              if (factory.XmlName == "thumbnail")
            img = ((Google.GData.Extensions.XmlExtension)factory).Node.Attributes[0].Value;
            }
              }
              catch
              {
              }
              entry.SetValue("imgurl", img);
              GenericListItem listItem = new GenericListItem()
              {
            Title = entry.Title,
            IsFolder = true,
            LogoUrl = img,
            Tag = entry
              };
              res.Items.Add(listItem);
              return res;
        }
Ejemplo n.º 7
0
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            res.Title = entry.Title;
            res.Add(VevoFavorite());
            res.Add(VevoUploads());
            List <ArtistItem> artists = ArtistManager.Instance.GetVevoArtists();

            foreach (ArtistItem artistItem in artists)
            {
                UserVideos    userVideos = new UserVideos();
                SiteItemEntry itemEntry  = new SiteItemEntry();
                itemEntry.Provider = userVideos.Name;
                itemEntry.SetValue("id", artistItem.User);
                string          title    = artistItem.Name;
                GenericListItem listItem = new GenericListItem()
                {
                    Title        = title,
                    IsFolder     = false,
                    LogoUrl      = artistItem.Img_url,
                    DefaultImage = "defaultArtistBig.png",
                    Tag          = itemEntry
                };
                res.Add(listItem);
            }
            res.ItemType = ItemType.Artist;
            return(res);
        }
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            res.FolderType = 1;
            string user = entry.GetValue("user");

            user = string.IsNullOrEmpty(user) ? "default" : user;
            YouTubeQuery query =
                new YouTubeQuery(string.Format("http://gdata.youtube.com/feeds/api/users/{0}/favorites", user));

            query.NumberToRetrieve = Youtube2MP.ITEM_IN_LIST;
            query.StartIndex       = entry.StartItem;
            if (entry.StartItem > 1)
            {
                res.Paged = true;
            }
            YouTubeFeed videos = Youtube2MP.service.Query(query);

            res.Title = videos.Title.Text;
            foreach (YouTubeEntry youTubeEntry in videos.Entries)
            {
                res.Items.Add(Youtube2MP.YouTubeEntry2ListItem(youTubeEntry));
            }
            res.Add(Youtube2MP.GetPager(entry, videos));
            res.ItemType = ItemType.Video;
            return(res);
        }
Ejemplo n.º 9
0
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            res.Title = entry.Title;
            YouTubeQuery query =
                new YouTubeQuery(string.Format("http://gdata.youtube.com/feeds/api/users/{0}/uploads", entry.GetValue("id")));

            if (string.IsNullOrEmpty(entry.GetValue("id")))
            {
                query =
                    new YouTubeQuery(string.Format("http://gdata.youtube.com/feeds/api/users/default/uploads"));
            }
            query.NumberToRetrieve = Youtube2MP.ITEM_IN_LIST;
            query.StartIndex       = entry.StartItem;
            if (entry.StartItem > 1)
            {
                res.Paged = true;
            }
            YouTubeFeed videos = Youtube2MP.service.Query(query);

            res.Title = "Uploads by :" + videos.Authors[0].Name;
            foreach (YouTubeEntry youTubeEntry in videos.Entries)
            {
                res.Items.Add(Youtube2MP.YouTubeEntry2ListItem(youTubeEntry));
            }
            res.Add(Youtube2MP.GetPager(entry, videos));
            res.ItemType = ItemType.Video;
            return(res);
        }
Ejemplo n.º 10
0
        public GenericListItemCollections HomeGetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            string       feedUrl = "http://gdata.youtube.com/feeds/api/users/" + entry.GetValue("id");
            ProfileEntry profile = (ProfileEntry)Youtube2MP.service.Get(feedUrl);

            string img = "";

            try
            {
                foreach (IExtensionElementFactory factory in profile.ExtensionElements)
                {
                    if (factory.XmlName == "thumbnail")
                    {
                        img = ((Google.GData.Extensions.XmlExtension)factory).Node.Attributes[0].Value;
                    }
                }
            }
            catch
            {
            }
            entry.SetValue("imgurl", img);
            GenericListItem listItem = new GenericListItem()
            {
                Title    = entry.Title,
                IsFolder = true,
                LogoUrl  = img,
                Tag      = entry
            };

            res.Items.Add(listItem);
            return(res);
        }
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            res.Title = entry.Title;
            int count = 0;
            int ii    = 0;

            int.TryParse(entry.GetValue("items"), out ii);

            for (int i = Youtube2MP._settings.SearchHistory.Count; i > 0; i--)
            {
                count++;
                SiteItemEntry newentry    = new SiteItemEntry();
                SearchVideo   searchVideo = new SearchVideo();
                newentry.Provider = searchVideo.Name;
                newentry.SetValue("term", Youtube2MP._settings.SearchHistory[i - 1]);
                GenericListItem listItem = new GenericListItem()
                {
                    Title    = "Search result for :" + Youtube2MP._settings.SearchHistory[i - 1],
                    IsFolder = true,
                    //LogoUrl = YoutubeGUIBase.GetBestUrl(youTubeEntry.Media.Thumbnails),
                    Tag = newentry
                };
                res.Items.Add(listItem);
                if (count > ii)
                {
                    break;
                }
            }
            return(res);
        }
Ejemplo n.º 12
0
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            res.Title = entry.Title;
            User user = new User(Youtube2MP._settings.LastFmUser, Youtube2MP.LastFmProfile.Session);

            switch (entry.GetValue("type"))
            {
            case "TopTracks":
            {
                TopTrack[] tracks = user.GetTopTracks();
                //user.GetRecentTracks()
                foreach (TopTrack topTrack in tracks)
                {
                    SiteItemEntry newentry  = new SiteItemEntry();
                    VideoItem     videoItem = new VideoItem();
                    newentry.Provider = videoItem.Name;
                    newentry.Title    = topTrack.Item.ToString();
                    res.Items.Add(new GenericListItem()
                        {
                            IsFolder     = false,
                            Title        = newentry.Title,
                            Tag          = newentry,
                            LogoUrl      = ArtistManager.Instance.GetArtistsImgUrl(topTrack.Item.Artist.Name),
                            DefaultImage = "defaultArtistBig.png"
                        });
                }
            }
            break;

            case "RecentTracks":
            {
                Track[] tracks = user.GetRecentTracks(40);
                //user.GetRecentTracks()
                foreach (Track topTrack in tracks)
                {
                    SiteItemEntry newentry  = new SiteItemEntry();
                    VideoItem     videoItem = new VideoItem();
                    newentry.Provider = videoItem.Name;
                    newentry.Title    = topTrack.ToString();
                    res.Items.Add(new GenericListItem()
                        {
                            IsFolder     = false,
                            Title        = newentry.Title,
                            Tag          = newentry,
                            LogoUrl      = ArtistManager.Instance.GetArtistsImgUrl(topTrack.Artist.Name),
                            DefaultImage = "defaultArtistBig.png"
                        });
                }
            }
            break;
            }
            res.ItemType = ItemType.Video;
            return(res);
        }
 public FormItemList(GenericListItemCollections listItems)
 {
     InitializeComponent();
     foreach (GenericListItem item in listItems.Items)
     {
         ListViewItem listViewItem = new ListViewItem(item.Title);
         listViewItem.Tag = item;
         listView1.Items.Add(listViewItem);
     }
 }
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();
              res.Title = entry.Title;
              User user = new User(Youtube2MP._settings.LastFmUser, Youtube2MP.LastFmProfile.Session);
              switch (entry.GetValue("type"))
              {
            case "TopTracks":
              {
            TopTrack[] tracks = user.GetTopTracks();
            //user.GetRecentTracks()
            foreach (TopTrack topTrack in tracks)
            {
              SiteItemEntry newentry = new SiteItemEntry();
              VideoItem videoItem = new VideoItem();
              newentry.Provider = videoItem.Name;
              newentry.Title = topTrack.Item.ToString();
              res.Items.Add(new GenericListItem()
              {
                IsFolder = false,
                Title = newentry.Title,
                Tag = newentry,
                LogoUrl = ArtistManager.Instance.GetArtistsImgUrl(topTrack.Item.Artist.Name),
                DefaultImage = "defaultArtistBig.png"
              });
            }
              }
              break;
            case "RecentTracks":
              {
            Track[] tracks = user.GetRecentTracks(40);
            //user.GetRecentTracks()
            foreach (Track topTrack in tracks)
            {
              SiteItemEntry newentry = new SiteItemEntry();
              VideoItem videoItem = new VideoItem();
              newentry.Provider = videoItem.Name;
              newentry.Title = topTrack.ToString();
              res.Items.Add(new GenericListItem()
              {
                IsFolder = false,
                Title = newentry.Title,
                Tag = newentry,
                LogoUrl = ArtistManager.Instance.GetArtistsImgUrl(topTrack.Artist.Name),
                DefaultImage = "defaultArtistBig.png"

              });
            }
              }
              break;
              }
              res.ItemType = ItemType.Video;
              return res;
        }
 public GenericListItemCollections GetList(SiteItemEntry entry)
 {
     GenericListItemCollections res = new GenericListItemCollections();
       res.Title = entry.Title;
       foreach (SiteItemEntry itemEntry in entry.Parent.Items)
       {
     if (itemEntry.ParentFolder == entry.Title)
       res.Items.Add(new GenericListItem {Title = itemEntry.Title, Tag = itemEntry, IsFolder = true,});
       }
       return res;
 }
 public GenericListItemCollections GetList(SiteItemEntry entry)
 {
     GenericListItemCollections res = new GenericListItemCollections();
       res.Title = entry.Title;
       foreach (SiteItemEntry itemEntry in _menu.Items)
       {
     if (string.IsNullOrEmpty(itemEntry.ParentFolder))
       res.Add(Youtube2MP.SiteItemProvider[itemEntry.Provider].HomeGetList(itemEntry));
       }
       return res;
 }
Ejemplo n.º 17
0
        public GenericListItemCollections HomeGetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            res.Items.Add(new GenericListItem()
            {
                IsFolder = true,
                Title    = entry.Title,
                Tag      = entry
            });
            return(res);
        }
 public GenericListItemCollections HomeGetList(SiteItemEntry entry)
 {
     GenericListItemCollections res = new GenericListItemCollections();
       res.Items.Add(new GenericListItem()
       {
     IsFolder = true,
     Title = entry.Title,
     Tag =entry
       // new SiteItemEntry() { Provider = "Artists" }
       });
       return res;
 }
 public GenericListItemCollections HomeGetList(SiteItemEntry entry)
 {
     GenericListItemCollections res = new GenericListItemCollections();
       //entry.Title = Name;
       GenericListItem listItem = new GenericListItem()
       {
     Title = entry.Title,
     IsFolder = true,
     //LogoUrl = YoutubeGUIBase.GetBestUrl(youTubeEntry.Media.Thumbnails),
     Tag = entry
       };
       res.Items.Add(listItem);
       return res;
 }
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            if (entry.GetValue("all") == "true" && entry.GetValue("level") != "false")
            {
                res.Title = entry.Title;
                foreach (KeyValuePair <string, string> keyValuePair in Feeds)
                {
                    SiteItemEntry newentry  = new SiteItemEntry();
                    BillboardItem videoItem = new BillboardItem();
                    newentry.Provider = videoItem.Name;
                    newentry.Title    = keyValuePair.Key;
                    newentry.SetValue("feed", keyValuePair.Key);
                    res.Items.Add(new GenericListItem()
                    {
                        IsFolder = false,
                        Title    = newentry.Title,
                        Tag      = newentry
                    });
                }
            }
            else
            {
                string rssurl = Feeds[entry.GetValue("feed")];
                res.ItemType = ItemType.Video;
                Uri        uri          = new Uri(rssurl);
                RssChannel myRssChannel = new RssChannel(uri);
                res.Title = myRssChannel.Title;
                foreach (RssItem item in myRssChannel.Items)
                {
                    SiteItemEntry newentry  = new SiteItemEntry();
                    VideoItem     videoItem = new VideoItem();
                    newentry.Provider = videoItem.Name;
                    newentry.Title    = item.Title;
                    newentry.SetValue("level", "false");
                    string[] title = item.Title.Split(',');
                    newentry.SetValue("search", title[1].Trim() + " - " + title[0].Split(':')[1]);
                    res.Items.Add(new GenericListItem()
                    {
                        IsFolder     = false,
                        Title        = newentry.Title,
                        Tag          = newentry,
                        LogoUrl      = ArtistManager.Instance.GetArtistsImgUrl(GetArtistName(title[1])),
                        DefaultImage = "defaultArtistBig.png"
                    });
                }
            }
            return(res);
        }
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            res.Title = entry.Title;
            foreach (SiteItemEntry itemEntry in _menu.Items)
            {
                if (string.IsNullOrEmpty(itemEntry.ParentFolder))
                {
                    res.Add(Youtube2MP.SiteItemProvider[itemEntry.Provider].HomeGetList(itemEntry));
                }
            }
            return(res);
        }
 public GenericListItemCollections GetList(SiteItemEntry entry)
 {
     GenericListItemCollections res = new GenericListItemCollections();
       if (entry.GetValue("all") == "true" && entry.GetValue("level") != "false")
       {
     res.Title = entry.Title;
     foreach (KeyValuePair<string, string> keyValuePair in Feeds)
     {
       SiteItemEntry newentry = new SiteItemEntry();
       BillboardItem videoItem = new BillboardItem();
       newentry.Provider = videoItem.Name;
       newentry.Title = keyValuePair.Key;
       newentry.SetValue("feed", keyValuePair.Key);
       res.Items.Add(new GenericListItem()
       {
     IsFolder = false,
     Title = newentry.Title,
     Tag = newentry
       });
     }
       }
       else
       {
     string rssurl = Feeds[entry.GetValue("feed")];
     res.ItemType = ItemType.Video;
     Uri uri = new Uri(rssurl);
     RssChannel myRssChannel = new RssChannel(uri);
     res.Title = myRssChannel.Title;
     foreach (RssItem item in myRssChannel.Items)
     {
       SiteItemEntry newentry = new SiteItemEntry();
       VideoItem videoItem = new VideoItem();
       newentry.Provider = videoItem.Name;
       newentry.Title = item.Title;
       newentry.SetValue("level", "false");
       string[] title = item.Title.Split(',');
       newentry.SetValue("search", title[1].Trim() + " - " + title[0].Split(':')[1]);
       res.Items.Add(new GenericListItem()
                   {
                     IsFolder = false,
                     Title = newentry.Title,
                     Tag = newentry,
                     LogoUrl = ArtistManager.Instance.GetArtistsImgUrl(GetArtistName(title[1])),
                     DefaultImage = "defaultArtistBig.png"
                   });
     }
       }
       return res;
 }
        public GenericListItemCollections HomeGetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            res.Items.Add(new GenericListItem()
            {
                IsFolder = true,
                Title    = "User Downloaded Videos",
                Tag      = new SiteItemEntry()
                {
                    Provider = "UserDownloadedVideos"
                }
            });
            return(res);
        }
        public GenericListItemCollections HomeGetList(SiteItemEntry itemEntry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            GenericListItem listItem = new GenericListItem()
            {
                Title    = itemEntry.Title,
                IsFolder = true,
                //LogoUrl = YoutubeGUIBase.GetBestUrl(youTubeEntry.Media.Thumbnails),
                Tag = itemEntry
            };

            res.Items.Add(listItem);
            return(res);
        }
Ejemplo n.º 25
0
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            res.Title = entry.Title;
            foreach (SiteItemEntry itemEntry in entry.Parent.Items)
            {
                if (itemEntry.ParentFolder == entry.Title)
                {
                    res.Items.Add(new GenericListItem {
                        Title = itemEntry.Title, Tag = itemEntry, IsFolder = true,
                    });
                }
            }
            return(res);
        }
        public GenericListItemCollections GetRecentlyPlayed()
        {
            GenericListItemCollections res = new GenericListItemCollections();

            try
            {
                string lsSQL =
                    string.Format(
                        "SELECT VIDEOS.VIDEO_ID AS VIDEO_ID, ARTIST_ID, TITLE, IMG_URL FROM VIDEOS, PLAY_HISTORY WHERE VIDEOS.VIDEO_ID=PLAY_HISTORY.VIDEO_ID order by datePlayed DESC");
                SQLiteResultSet loResultSet = m_db.Execute(lsSQL);
                string          lastid      = "";
                for (int iRow = 0; iRow < loResultSet.Rows.Count; iRow++)
                {
                    YouTubeEntry youTubeEntry = new YouTubeEntry();
                    if (lastid == DatabaseUtility.Get(loResultSet, iRow, "VIDEO_ID"))
                    {
                        continue;
                    }
                    lastid = DatabaseUtility.Get(loResultSet, iRow, "VIDEO_ID");
                    youTubeEntry.AlternateUri =
                        new AtomUri("http://www.youtube.com/watch?v=" + DatabaseUtility.Get(loResultSet, iRow, "VIDEO_ID"));
                    youTubeEntry.Title             = new AtomTextConstruct();
                    youTubeEntry.Title.Text        = DatabaseUtility.Get(loResultSet, iRow, "TITLE");
                    youTubeEntry.Media             = new MediaGroup();
                    youTubeEntry.Media.Description = new MediaDescription("");
                    youTubeEntry.Id = new AtomId(youTubeEntry.AlternateUri.Content);
                    GenericListItem listItem = new GenericListItem()
                    {
                        Title    = youTubeEntry.Title.Text,
                        IsFolder = false,
                        LogoUrl  = DatabaseUtility.Get(loResultSet, iRow, "IMG_URL"),
                        Tag      = youTubeEntry,
                        //ParentTag = artistItem
                    };
                    res.Items.Add(listItem);
                }
                ;
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }
            return(res);
        }
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            res.Title = entry.Title;
            if (string.IsNullOrEmpty(entry.GetValue("level")))
            {
                for (int i = 0; i < stats.Count; i++)
                {
                    SiteItemEntry newentry   = new SiteItemEntry();
                    Statistics    statistics = new Statistics();
                    newentry.Provider = statistics.Name;
                    newentry.Title    = stats[i];
                    newentry.SetValue("level", i.ToString());
                    res.Items.Add(new GenericListItem()
                    {
                        IsFolder = true,
                        Title    = newentry.Title,
                        Tag      = newentry,
                        //LogoUrl = ArtistManager.Instance.GetArtistsImgUrl(GetArtistName(title[1]))
                    });
                }
            }
            if (entry.GetValue("level") == "0")//Recently played videos
            {
                res          = DatabaseProvider.InstanInstance.GetRecentlyPlayed();
                res.Title    = Name + "/" + stats[0];
                res.ItemType = ItemType.Video;
            }
            if (entry.GetValue("level") == "1")//Recently played videos
            {
                res          = DatabaseProvider.InstanInstance.GetTopPlayed();
                res.Title    = Name + "/" + stats[1];
                res.ItemType = ItemType.Video;
            }
            if (entry.GetValue("level") == "2")//Recently played videos
            {
                res          = DatabaseProvider.InstanInstance.GetRandom();
                res.Title    = Name + "/" + stats[2];
                res.ItemType = ItemType.Video;
            }
            return(res);
        }
 public GenericListItemCollections GetList(SiteItemEntry entry)
 {
     GenericListItemCollections res = new GenericListItemCollections();
       res.Title = entry.Title;
       if (string.IsNullOrEmpty(entry.GetValue("level")))
       {
     for (int i = 0; i < stats.Count; i++)
     {
       SiteItemEntry newentry = new SiteItemEntry();
       Statistics statistics = new Statistics();
       newentry.Provider = statistics.Name;
       newentry.Title = stats[i];
       newentry.SetValue("level", i.ToString());
       res.Items.Add(new GenericListItem()
                   {
                     IsFolder = true,
                     Title = newentry.Title,
                     Tag = newentry,
                     //LogoUrl = ArtistManager.Instance.GetArtistsImgUrl(GetArtistName(title[1]))
                   });
     }
       }
       if (entry.GetValue("level") == "0")//Recently played videos
       {
     res = DatabaseProvider.InstanInstance.GetRecentlyPlayed();
     res.Title = Name + "/" + stats[0];
     res.ItemType = ItemType.Video;
       }
       if (entry.GetValue("level") == "1")//Recently played videos
       {
     res = DatabaseProvider.InstanInstance.GetTopPlayed();
     res.Title = Name + "/" + stats[1];
     res.ItemType = ItemType.Video;
       }
       if (entry.GetValue("level") == "2")//Recently played videos
       {
     res =  DatabaseProvider.InstanInstance.GetRandom();
     res.Title = Name + "/" + stats[2];
     res.ItemType = ItemType.Video;
       }
       return res;
 }
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            res.Title = entry.Title;
            YouTubeQuery  query         = new YouTubeQuery(YouTubeQuery.CreatePlaylistsUri(entry.GetValue("id")));
            PlaylistsFeed userPlaylists = Youtube2MP.service.GetPlaylists(query);

            res.Title = userPlaylists.Title.Text;
            foreach (PlaylistsEntry playlistsEntry in userPlaylists.Entries)
            {
                Google.GData.Extensions.XmlExtension e = playlistsEntry.FindExtension("group", "http://search.yahoo.com/mrss/") as Google.GData.Extensions.XmlExtension;

                string img = "http://i2.ytimg.com/vi/hqdefault.jpg";
                try
                {
                    img = e.Node.FirstChild.Attributes["url"].Value;
                }
                catch
                {
                }

                PlayList playList = new PlayList();

                SiteItemEntry itemEntry = new SiteItemEntry();
                itemEntry.Provider = playList.Name;
                itemEntry.SetValue("url", playlistsEntry.Content.AbsoluteUri);
                string          title    = playlistsEntry.Title.Text;
                GenericListItem listItem = new GenericListItem()
                {
                    Title    = title,
                    IsFolder = false,
                    LogoUrl  = img.Replace("default", "hqdefault"),
                    //DefaultImage = "defaultArtistBig.png",
                    Tag = itemEntry
                };
                res.Add(listItem);
            }
            res.ItemType = ItemType.Item;
            return(res);
        }
        public GenericListItemCollections GetTopPlayed(int numPlay)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            try
            {
                string lsSQL =
                    string.Format(
                        "select * from (SELECT VIDEOS.VIDEO_ID AS VIDEO_ID, ARTIST_ID, TITLE, IMG_URL, count(PLAY_HISTORY.VIDEO_ID) as num_play FROM VIDEOS, PLAY_HISTORY WHERE VIDEOS.VIDEO_ID=PLAY_HISTORY.VIDEO_ID group by VIDEOS.VIDEO_ID, ARTIST_ID, TITLE, IMG_URL order by count(PLAY_HISTORY.VIDEO_ID) desc)where num_play>" +
                        numPlay.ToString());
                SQLiteResultSet loResultSet = m_db.Execute(lsSQL);
                for (int iRow = 0; iRow < loResultSet.Rows.Count; iRow++)
                {
                    YouTubeEntry youTubeEntry = new YouTubeEntry();

                    youTubeEntry.AlternateUri      = new AtomUri("http://www.youtube.com/watch?v=" + DatabaseUtility.Get(loResultSet, iRow, "VIDEO_ID"));
                    youTubeEntry.Title             = new AtomTextConstruct();
                    youTubeEntry.Title.Text        = DatabaseUtility.Get(loResultSet, iRow, "TITLE");
                    youTubeEntry.Media             = new MediaGroup();
                    youTubeEntry.Media.Description = new MediaDescription("");
                    youTubeEntry.Id = new AtomId(youTubeEntry.AlternateUri.Content);
                    GenericListItem listItem = new GenericListItem()
                    {
                        Title    = youTubeEntry.Title.Text,
                        IsFolder = false,
                        LogoUrl  = DatabaseUtility.Get(loResultSet, iRow, "IMG_URL"),
                        Tag      = youTubeEntry,
                        Title2   = DatabaseUtility.Get(loResultSet, iRow, "num_play"),
                        //ParentTag = artistItem
                    };
                    res.Items.Add(listItem);
                }
                ;
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }
            return(res);
        }
 public GenericListItemCollections GetList(SiteItemEntry entry)
 {
     GenericListItemCollections res = new GenericListItemCollections();
       res.FolderType = 1;
       string user = entry.GetValue("user");
       user = string.IsNullOrEmpty(user) ? "default" : user;
       YouTubeQuery query =
     new YouTubeQuery(string.Format("http://gdata.youtube.com/feeds/api/users/{0}/favorites",user));
       query.NumberToRetrieve = Youtube2MP.ITEM_IN_LIST;
       query.StartIndex = entry.StartItem;
       if (entry.StartItem > 1)
     res.Paged = true;
       YouTubeFeed videos = Youtube2MP.service.Query(query);
       res.Title = videos.Title.Text;
       foreach (YouTubeEntry youTubeEntry in videos.Entries)
       {
     res.Items.Add(Youtube2MP.YouTubeEntry2ListItem(youTubeEntry));
       }
       res.Add(Youtube2MP.GetPager(entry, videos));
       res.ItemType = ItemType.Video;
       return res;
 }
        static public GenericListItemCollections GetHomeMenu()
        {
            GenericListItemCollections res = new GenericListItemCollections();

            res.Title = "Home";
            foreach (SiteItemEntry itemEntry in _settings.MainMenu.Items)
            {
                if (String.IsNullOrEmpty(itemEntry.ParentFolder))
                {
                    res.Add(SiteItemProvider[itemEntry.Provider].HomeGetList(itemEntry));
                }
            }
            foreach (GenericListItem genericListItem in res.Items)
            {
                string file = GUIGraphicsContext.Skin + "\\Media\\Youtube.Fm\\" + genericListItem.Title + ".png";
                if (File.Exists(file))
                {
                    genericListItem.DefaultImage = file;
                }
            }
            return(res);
        }
Ejemplo n.º 33
0
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            res.Title = entry.Title;
            {
                SiteItemEntry itemEntry = new SiteItemEntry();
                itemEntry.Provider = new UserPlaylists().Name;
                itemEntry.SetValue("id", entry.GetValue("id"));
                string          title    = "Playlist";
                GenericListItem listItem = new GenericListItem()
                {
                    Title    = title,
                    IsFolder = false,
                    LogoUrl  = entry.GetValue("imgurl"),
                    //DefaultImage = "defaultArtistBig.png",
                    Tag = itemEntry
                };
                res.Add(listItem);
            }
            {
                SiteItemEntry itemEntry = new SiteItemEntry();
                itemEntry.Provider = new UserVideos().Name;
                itemEntry.SetValue("id", entry.GetValue("id"));
                string          title    = "Uploads";
                GenericListItem listItem = new GenericListItem()
                {
                    Title    = title,
                    IsFolder = false,
                    LogoUrl  = entry.GetValue("imgurl"),
                    //DefaultImage = "defaultArtistBig.png",
                    Tag = itemEntry
                };
                res.Add(listItem);
            }
            res.ItemType = ItemType.Item;
            return(res);
        }
 public GenericListItemCollections GetList(SiteItemEntry entry)
 {
     GenericListItemCollections res = new GenericListItemCollections();
       res.Title = entry.Title;
       YouTubeQuery query =
     new YouTubeQuery(string.Format("http://gdata.youtube.com/feeds/api/users/{0}/uploads", entry.GetValue("id")));
       if (string.IsNullOrEmpty(entry.GetValue("id")))
     query =
       new YouTubeQuery(string.Format("http://gdata.youtube.com/feeds/api/users/default/uploads"));
       query.NumberToRetrieve = Youtube2MP.ITEM_IN_LIST;
       query.StartIndex = entry.StartItem;
       if (entry.StartItem > 1)
     res.Paged = true;
       YouTubeFeed videos = Youtube2MP.service.Query(query);
       res.Title = "Uploads by :" + videos.Authors[0].Name;
       foreach (YouTubeEntry youTubeEntry in videos.Entries)
       {
     res.Items.Add(Youtube2MP.YouTubeEntry2ListItem(youTubeEntry));
       }
       res.Add(Youtube2MP.GetPager(entry, videos));
       res.ItemType = ItemType.Video;
       return res;
 }
 public GenericListItemCollections GetList(SiteItemEntry entry)
 {
     GenericListItemCollections res = new GenericListItemCollections();
       res.Title = entry.Title;
       {
     SiteItemEntry itemEntry = new SiteItemEntry();
     itemEntry.Provider = new UserPlaylists().Name;
     itemEntry.SetValue("id", entry.GetValue("id"));
     string title = "Playlist";
     GenericListItem listItem = new GenericListItem()
     {
       Title = title,
       IsFolder = false,
       LogoUrl = entry.GetValue("imgurl"),
       //DefaultImage = "defaultArtistBig.png",
       Tag = itemEntry
     };
     res.Add(listItem);
       }
       {
     SiteItemEntry itemEntry = new SiteItemEntry();
     itemEntry.Provider = new UserVideos().Name;
     itemEntry.SetValue("id", entry.GetValue("id"));
     string title = "Uploads";
     GenericListItem listItem = new GenericListItem()
     {
       Title = title,
       IsFolder = false,
       LogoUrl = entry.GetValue("imgurl"),
       //DefaultImage = "defaultArtistBig.png",
       Tag = itemEntry
     };
     res.Add(listItem);
       }
       res.ItemType = ItemType.Item;
       return res;
 }
Ejemplo n.º 36
0
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();
            YouTubeQuery query             = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);

            query.Query = string.IsNullOrEmpty(entry.GetValue("search")) ? entry.Title : entry.GetValue("search");

            query.NumberToRetrieve = 1;
            query.OrderBy          = "relevance";

            if (Youtube2MP._settings.MusicFilter)
            {
                query.Categories.Add(new QueryCategory("Music", QueryCategoryOperator.AND));
            }

            YouTubeFeed videos = Youtube2MP.service.Query(query);

            foreach (YouTubeEntry youTubeEntry in videos.Entries)
            {
                res.Items.Add(Youtube2MP.YouTubeEntry2ListItem(youTubeEntry));
            }
            res.FolderType = 1;
            return(res);
        }
 public GenericListItemCollections GetList(SiteItemEntry entry)
 {
     GenericListItemCollections res = new GenericListItemCollections();
       res.FolderType = 1;
       string url = string.Format("http://gdata.youtube.com/feeds/api/playlists/{0}", entry.GetValue("id"));
       if (!string.IsNullOrEmpty(entry.GetValue("url")))
     url = entry.GetValue("url");
       YouTubeQuery query = new YouTubeQuery(url);
       query.NumberToRetrieve = 50;
       do
       {
     YouTubeFeed videos = Youtube2MP.service.Query(query);
     res.Title = videos.Title.Text;
     foreach (YouTubeEntry youTubeEntry in videos.Entries)
     {
       res.Items.Add(Youtube2MP.YouTubeEntry2ListItem(youTubeEntry));
     }
     query.StartIndex += 50;
     if (videos.TotalResults < query.StartIndex + 50)
       break;
       } while (true);
       res.ItemType = ItemType.Video;
       return res;
 }
        public GenericListItemCollections GetArtistVideosIds(string artist_name)
        {
            string site = DownloadArtistInfo(artist_name);
              GetSimilarArtistsSite(site);
              string playlist_id = null;
              try
              {
            Regex regexObj = new Regex("data-list_id=\"(?<name>.*?)\"", RegexOptions.Singleline);
            playlist_id = regexObj.Match(site).Groups["name"].Value;
              }
              catch (ArgumentException ex)
              {
            // Syntax error in the regular expression
              }
              site = DownloadString(string.Format("http://www.youtube.com/playlist?list={0}", playlist_id));

              GenericListItemCollections res = new GenericListItemCollections();
              try
              {
            //------------------------------
            //string img = Regex.Match(site, "<img class=\"artist-image\" src=\"(?<url>.*?)\" />", RegexOptions.Singleline).Groups["url"].Value;
            //ArtistItem artistItem = ArtistManager.Instance.GetArtistsById(artist_id);
            //artistItem.Img_url = img;
            //ArtistManager.Instance.Save(artistItem);
            //----------------------------
            //@"<li class=""playlist-video-item.*?<a href=""/watch\?v=(?<vid_id>.*?)&.*?data-thumb=""(?<thumb>.*?)"".*?<span class=""video-time"">(?<duration>.*?)</span>"

            //Regex regexObj = new Regex("album-row.*?data-video-ids=\"(?<vid_id>.*?)\".*?<span class=\"clip\"><img src=\"(?<thumb>.*?)\".*?album-track-name\">(?<title>.*?)</span>", RegexOptions.Singleline);
            Regex regexObj = new Regex(@"playlist-video-item.*?<a href=""/watch\?v=(?<vid_id>.*?)&.*?data-thumb=""(?<thumb>.*?)"".*?<span class=""video-time"">(?<duration>.*?)</span>.*?video-title ""  dir=""ltr"">(?<title>.*?)</span>", RegexOptions.Singleline);
            Match matchResult = regexObj.Match(site);
            while (matchResult.Success)
            {
              YouTubeEntry youTubeEntry=new YouTubeEntry();

              youTubeEntry.AlternateUri = new AtomUri("http://www.youtube.com/watch?v=" + matchResult.Groups["vid_id"].Value);
              youTubeEntry.Title = new AtomTextConstruct();
              youTubeEntry.Title.Text =HttpUtility.HtmlDecode(matchResult.Groups["title"].Value);
              youTubeEntry.Media = new MediaGroup();
              youTubeEntry.Media.Description = new MediaDescription("");
              youTubeEntry.Id = new AtomId(youTubeEntry.AlternateUri.Content);
              GenericListItem listItem = new GenericListItem()
                                       {
                                         Title = youTubeEntry.Title.Text,
                                         IsFolder = false,
                                         LogoUrl = "http:" + matchResult.Groups["thumb"].Value.Replace("default.jpg", "hqdefault.jpg"),
                                         Tag = youTubeEntry,
                                         Title2 = matchResult.Groups["duration"].Value,
                                         //ParentTag = artistItem
                                       };
              res.Items.Add(listItem);
              //resultList.Add(matchResult.Groups["groupname"].Value);
              matchResult = matchResult.NextMatch();
            }
              }
              catch (Exception ex)
              {
            // Syntax error in the regular expression
              }
              res.ItemType = ItemType.Video;
              return res;
        }
        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);
            }
        }
Ejemplo n.º 40
0
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            res.Title = entry.Title;
            if (string.IsNullOrEmpty(entry.GetValue("level")))
            {
                foreach (KeyValuePair <string, string> keyValuePair in _settings.Regions)
                {
                    SiteItemEntry newentry = new SiteItemEntry();
                    newentry.Provider = this.Name;
                    newentry.SetValue("region", keyValuePair.Key);
                    newentry.SetValue("level", "1");
                    newentry.Title = keyValuePair.Key;
                    GenericListItem listItem = new GenericListItem()
                    {
                        Title    = keyValuePair.Key,
                        IsFolder = true,
                        Tag      = newentry
                    };
                    res.Items.Add(listItem);
                }
            }
            else if (entry.GetValue("level") == "1")
            {
                {
                    SiteItemEntry newentry = new SiteItemEntry();
                    newentry.Provider = this.Name;
                    newentry.SetValue("region", entry.GetValue("region"));
                    newentry.SetValue("level", "2");
                    newentry.SetValue("hd", "false");
                    newentry.Title = entry.Title + "/" + "All";
                    GenericListItem listItem = new GenericListItem()
                    {
                        Title    = "All",
                        IsFolder = true,
                        Tag      = newentry
                    };
                    res.Items.Add(listItem);
                }
                {
                    SiteItemEntry newentry = new SiteItemEntry();
                    newentry.Provider = this.Name;
                    newentry.SetValue("region", entry.GetValue("region"));
                    newentry.SetValue("level", "2");
                    newentry.SetValue("hd", "true");
                    newentry.Title = entry.Title + "/" + "HD";
                    GenericListItem listItem = new GenericListItem()
                    {
                        Title    = "HD",
                        IsFolder = true,
                        Tag      = newentry
                    };
                    res.Items.Add(listItem);
                }
            }
            else if (entry.GetValue("level") == "2")
            {
                for (int i = 0; i < _settings.Cats.Count; i++)
                {
                    SiteItemEntry newentry = new SiteItemEntry();
                    newentry.Provider = i > 4 ? "Standard feed" : this.Name;
                    newentry.SetValue("region", entry.GetValue("region"));
                    newentry.SetValue("hd", entry.GetValue("hd"));
                    newentry.SetValue("level", "3");
                    newentry.SetValue("feedint", i.ToString());
                    newentry.Title = entry.Title + "/" + _settings.Cats[i];
                    GenericListItem listItem = new GenericListItem()
                    {
                        Title    = _settings.Cats[i],
                        IsFolder = true,
                        Tag      = newentry
                    };
                    res.Items.Add(listItem);
                }
            }
            else if (entry.GetValue("level") == "3")
            {
                for (int i = 0; i < _settings.TimeList.Count; i++)
                {
                    SiteItemEntry newentry = new SiteItemEntry();
                    newentry.Provider = "Standard feed";
                    newentry.SetValue("region", entry.GetValue("region"));
                    newentry.SetValue("hd", entry.GetValue("hd"));
                    newentry.SetValue("level", "4");
                    newentry.SetValue("feedint", entry.GetValue("feedint"));
                    newentry.SetValue("time", _settings.TimeList[i]);
                    newentry.Title = entry.Title + "/" + _settings.TimeList[i];
                    GenericListItem listItem = new GenericListItem()
                    {
                        Title    = _settings.TimeList[i],
                        IsFolder = true,
                        Tag      = newentry
                    };
                    res.Items.Add(listItem);
                }
            }
            return(res);
        }
Ejemplo n.º 41
0
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            if (items.Items.Count > 0)
            {
                return(items);
            }
            Dictionary <string, GenericListItem> list1 = new Dictionary <string, GenericListItem>();

            GenericListItemCollections res = new GenericListItemCollections();
            string query = YouTubeQuery.MostViewedVideo;

            res.Title = entry.Title;
            if (!string.IsNullOrEmpty(entry.GetValue("region")))
            {
                string reg = Youtube2MP._settings.Regions[entry.GetValue("region")];
                if (!string.IsNullOrEmpty(reg))
                {
                    query = query.Replace("standardfeeds", "standardfeeds/" + reg);
                }
            }
            else
            {
                if (Youtube2MP._settings.Regions.ContainsValue(Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.ToUpper()))
                {
                    query = query.Replace("standardfeeds", "standardfeeds/" + Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.ToUpper());
                }
            }
            query += "_Music";
            YouTubeQuery tubeQuery = new YouTubeQuery(query);

            tubeQuery.NumberToRetrieve = 50;
            tubeQuery.SafeSearch       = YouTubeQuery.SafeSearchValues.None;

            YouTubeFeed videos = Youtube2MP.service.Query(tubeQuery);

            foreach (YouTubeEntry youTubeEntry in videos.Entries)
            {
                list1.Add(Youtube2MP.GetVideoId(youTubeEntry), Youtube2MP.YouTubeEntry2ListItem(youTubeEntry));
            }
            GenericListItemCollections popular = DatabaseProvider.InstanInstance.GetTopPlayed(2);

            foreach (GenericListItem genericListItem in popular.Items)
            {
                YouTubeEntry youTubeEntry = genericListItem.Tag as YouTubeEntry;
                if (youTubeEntry != null && !list1.ContainsKey(Youtube2MP.GetVideoId(youTubeEntry)))
                {
                    list1.Add(Youtube2MP.GetVideoId(youTubeEntry), genericListItem);
                }
            }
            Random random = new Random();

            foreach (GenericListItem genericListItem in list1.Values)
            {
                if (res.Items.Count == 0)
                {
                    res.Items.Add(genericListItem);
                }
                else
                {
                    res.Items.Insert(random.Next(res.Items.Count - 1), genericListItem);
                }
            }
            items        = res;
            res.ItemType = ItemType.Video;
            return(res);
        }
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();
            string query   = YouTubeQuery.TopRatedVideo;
            bool   usetime = true;

            res.Title = entry.Title;
            switch (Convert.ToInt32(entry.GetValue("feedint")))
            {
            case 0:
                query = YouTubeQuery.MostViewedVideo;
                break;

            case 1:
                query = YouTubeQuery.TopRatedVideo;
                break;

            case 2:
                query = YouTubeQuery.RecentlyFeaturedVideo;
                break;

            case 3:
                query = YouTubeQuery.MostDiscussedVideo;
                break;

            case 4:
                query = YouTubeQuery.FavoritesVideo;
                break;

            case 5:
                usetime = false;
                query   = YouTubeQuery.MostLinkedVideo;
                break;

            case 6:
                usetime = false;
                query   = YouTubeQuery.MostRespondedVideo;
                break;

            case 7:
                usetime = false;
                query   = YouTubeQuery.MostRecentVideo;
                break;

            case 8:
                usetime = false;
                query   = YouTubeQuery.StandardFeeds + "most_shared";
                break;

            case 9:
                usetime = false;
                query   = YouTubeQuery.StandardFeeds + "on_the_web";
                break;
            }

            if (!string.IsNullOrEmpty(entry.GetValue("region")))
            {
                string reg = Youtube2MP._settings.Regions[entry.GetValue("region")];
                if (!string.IsNullOrEmpty(reg))
                {
                    query = query.Replace("standardfeeds", "standardfeeds/" + reg);
                }
            }

            if (Youtube2MP._settings.MusicFilter)
            {
                query += "_Music";
            }

            YouTubeQuery tubeQuery = new YouTubeQuery(query);

            tubeQuery.NumberToRetrieve = Youtube2MP.ITEM_IN_LIST;
            tubeQuery.StartIndex       = entry.StartItem;
            tubeQuery.SafeSearch       = YouTubeQuery.SafeSearchValues.None;
            if (!string.IsNullOrEmpty(entry.GetValue("hd")) && entry.GetValue("hd") == "true")
            {
                tubeQuery.ExtraParameters = "hd=true";
            }

            if (usetime)
            {
                if (entry.GetValue("time") == "Today")
                {
                    tubeQuery.Time = YouTubeQuery.UploadTime.Today;
                }
                if (entry.GetValue("time") == "This Week")
                {
                    tubeQuery.Time = YouTubeQuery.UploadTime.ThisWeek;
                }
                if (entry.GetValue("time") == "This Month")
                {
                    tubeQuery.Time = YouTubeQuery.UploadTime.ThisMonth;
                }
            }
            if (entry.StartItem > 1)
            {
                res.Paged = true;
            }
            YouTubeFeed videos = Youtube2MP.service.Query(tubeQuery);

            foreach (YouTubeEntry youTubeEntry in videos.Entries)
            {
                res.Items.Add(Youtube2MP.YouTubeEntry2ListItem(youTubeEntry));
            }

            res.Add(Youtube2MP.GetPager(entry, videos));
            res.FolderType = 1;
            res.ItemType   = ItemType.Video;
            return(res);
        }
        public GenericListItemCollections GetRecentlyPlayed()
        {
            GenericListItemCollections res = new GenericListItemCollections();
              try
              {
            string lsSQL =
              string.Format(
            "SELECT VIDEOS.VIDEO_ID AS VIDEO_ID, ARTIST_ID, TITLE, IMG_URL FROM VIDEOS, PLAY_HISTORY WHERE VIDEOS.VIDEO_ID=PLAY_HISTORY.VIDEO_ID order by datePlayed DESC");
            SQLiteResultSet loResultSet = m_db.Execute(lsSQL);
            string lastid = "";
            for (int iRow = 0; iRow < loResultSet.Rows.Count; iRow++)
            {
              YouTubeEntry youTubeEntry = new YouTubeEntry();
              if (lastid == DatabaseUtility.Get(loResultSet, iRow, "VIDEO_ID"))
            continue;
              lastid = DatabaseUtility.Get(loResultSet, iRow, "VIDEO_ID");
              youTubeEntry.AlternateUri =
            new AtomUri("http://www.youtube.com/watch?v=" + DatabaseUtility.Get(loResultSet, iRow, "VIDEO_ID"));
              youTubeEntry.Title = new AtomTextConstruct();
              youTubeEntry.Title.Text = DatabaseUtility.Get(loResultSet, iRow, "TITLE");
              youTubeEntry.Media = new MediaGroup();
              youTubeEntry.Media.Description = new MediaDescription("");
              youTubeEntry.Id = new AtomId(youTubeEntry.AlternateUri.Content);
              GenericListItem listItem = new GenericListItem()
                                       {
                                         Title = youTubeEntry.Title.Text,
                                         IsFolder = false,
                                         LogoUrl = DatabaseUtility.Get(loResultSet, iRow, "IMG_URL"),
                                         Tag = youTubeEntry,
                                         //ParentTag = artistItem
                                       };
              res.Items.Add(listItem);
            }
            ;

              }
              catch (Exception exception)
              {
            Log.Error(exception);
              }
              return res;
        }
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();
              res.Title = entry.Title;
              if (string.IsNullOrEmpty(entry.GetValue("level")))
              {
            foreach (KeyValuePair<string, string> keyValuePair in _settings.Regions)
            {
              SiteItemEntry newentry = new SiteItemEntry();
              newentry.Provider = this.Name;
              newentry.SetValue("region", keyValuePair.Key);
              newentry.SetValue("level", "1");
              newentry.Title = keyValuePair.Key;
              GenericListItem listItem = new GenericListItem()
                                       {
                                         Title = keyValuePair.Key,
                                         IsFolder = true,
                                         Tag = newentry
                                       };
              res.Items.Add(listItem);
            }
              }
              else if (entry.GetValue("level") == "1")
              {
            {
              SiteItemEntry newentry = new SiteItemEntry();
              newentry.Provider =this.Name;
              newentry.SetValue("region", entry.GetValue("region"));
              newentry.SetValue("level", "2");
              newentry.SetValue("hd", "false");
              newentry.Title = entry.Title + "/" + "All";
              GenericListItem listItem = new GenericListItem()
              {
            Title = "All",
            IsFolder = true,
            Tag = newentry
              };
              res.Items.Add(listItem);
            }
            {
              SiteItemEntry newentry = new SiteItemEntry();
              newentry.Provider = this.Name;
              newentry.SetValue("region", entry.GetValue("region"));
              newentry.SetValue("level", "2");
              newentry.SetValue("hd", "true");
              newentry.Title = entry.Title + "/" + "HD";
              GenericListItem listItem = new GenericListItem()
              {
            Title = "HD",
            IsFolder = true,
            Tag = newentry
              };
              res.Items.Add(listItem);
            }

              }
              else if (entry.GetValue("level") == "2")
              {
            for (int i = 0; i < _settings.Cats.Count; i++)
            {
              SiteItemEntry newentry = new SiteItemEntry();
              newentry.Provider = i > 4 ? "Standard feed" : this.Name;
              newentry.SetValue("region", entry.GetValue("region"));
              newentry.SetValue("hd", entry.GetValue("hd"));
              newentry.SetValue("level", "3");
              newentry.SetValue("feedint", i.ToString());
              newentry.Title = entry.Title + "/" + _settings.Cats[i];
              GenericListItem listItem = new GenericListItem()
              {
            Title = _settings.Cats[i],
            IsFolder = true,
            Tag = newentry
              };
              res.Items.Add(listItem);
            }
              }
              else if (entry.GetValue("level") == "3")
              {
            for (int i = 0; i < _settings.TimeList.Count; i++)
            {
              SiteItemEntry newentry = new SiteItemEntry();
              newentry.Provider = "Standard feed";
              newentry.SetValue("region", entry.GetValue("region"));
              newentry.SetValue("hd", entry.GetValue("hd"));
              newentry.SetValue("level", "4");
              newentry.SetValue("feedint", entry.GetValue("feedint"));
              newentry.SetValue("time", _settings.TimeList[i]);
              newentry.Title = entry.Title + "/" + _settings.TimeList[i];
              GenericListItem listItem = new GenericListItem()
              {
            Title = _settings.TimeList[i],
            IsFolder = true,
            Tag = newentry
              };
              res.Items.Add(listItem);
            }
              }
              return res;
        }
Ejemplo n.º 45
0
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();

            if (entry.GetValue("letter") == "")
            {
                {
                    res.Title = "Artists";
                    SiteItemEntry newentry1 = new SiteItemEntry();
                    newentry1.Provider = this.Name;
                    newentry1.SetValue("letter", "true");
                    newentry1.SetValue("special", "1");
                    newentry1.Title = Translation.PlayedArtists;
                    GenericListItem listItem1 = new GenericListItem()
                    {
                        Title    = Translation.PlayedArtists,
                        IsFolder = true,
                        Tag      = newentry1
                    };
                    res.Items.Add(listItem1);
                }

                {
                    res.Title = "Artists";
                    SiteItemEntry newentry1 = new SiteItemEntry();
                    newentry1.Provider = this.Name;
                    newentry1.SetValue("letter", "true");
                    newentry1.SetValue("special", "2");
                    newentry1.Title = Translation.ByTags;
                    GenericListItem listItem1 = new GenericListItem()
                    {
                        Title    = Translation.ByTags,
                        IsFolder = true,
                        Tag      = newentry1
                    };
                    res.Items.Add(listItem1);
                }

                foreach (string letter in ArtistManager.Instance.GetArtistsLetters())
                {
                    SiteItemEntry newentry = new SiteItemEntry();
                    newentry.Provider = this.Name;
                    newentry.SetValue("letter", "true");
                    newentry.SetValue("special", "false");
                    newentry.Title = letter;
                    GenericListItem listItem = new GenericListItem()
                    {
                        Title    = letter,
                        IsFolder = true,
                        Tag      = newentry
                    };
                    res.Items.Add(listItem);
                }
            }
            if (entry.GetValue("letter") == "true" && entry.GetValue("special") == "false")
            {
                res.Title = "Artists/Letter/" + entry.Title;
                List <ArtistItem> list = ArtistManager.Instance.GetArtists(entry.Title);
                if (list.Count > 500)
                {
                    foreach (string letter in ArtistManager.Instance.GetArtistsLetters(entry.Title))
                    {
                        SiteItemEntry newentry = new SiteItemEntry();
                        newentry.Provider = this.Name;
                        newentry.SetValue("letter", "true");
                        newentry.SetValue("special", "false");
                        newentry.Title = letter;
                        GenericListItem listItem = new GenericListItem()
                        {
                            Title    = letter,
                            IsFolder = true,
                            Tag      = newentry
                        };
                        res.Items.Add(listItem);
                    }
                }
                else
                {
                    foreach (ArtistItem artistItem in list)
                    {
                        SiteItemEntry newentry = new SiteItemEntry();
                        newentry.Provider = this.Name;
                        newentry.SetValue("letter", "false");
                        newentry.SetValue("id", artistItem.Id);
                        newentry.SetValue("name", artistItem.Name);
                        res.ItemType = ItemType.Artist;
                        GenericListItem listItem = new GenericListItem()
                        {
                            Title   = artistItem.Name,
                            LogoUrl =
                                string.IsNullOrEmpty(artistItem.Img_url.Trim()) ? "@" : artistItem.Img_url,
                            IsFolder     = true,
                            DefaultImage = "defaultArtistBig.png",
                            Tag          = newentry
                        };
                        res.Items.Add(listItem);
                    }
                }
            }
            if (entry.GetValue("special") == "1")
            {
                res.Title = "Artists/" + Translation.PlayedArtists;
                foreach (
                    ArtistItem artistItem in
                    ArtistManager.Instance.GetArtistsByIds(DatabaseProvider.InstanInstance.GetPlayedArtistIds(1)))
                {
                    SiteItemEntry newentry = new SiteItemEntry();
                    newentry.Provider = this.Name;
                    newentry.SetValue("letter", "false");
                    newentry.SetValue("id", artistItem.Id);
                    newentry.SetValue("name", artistItem.Name);
                    res.ItemType = ItemType.Artist;
                    GenericListItem listItem = new GenericListItem()
                    {
                        Title   = artistItem.Name,
                        LogoUrl =
                            string.IsNullOrEmpty(artistItem.Img_url.Trim()) ? "@" : artistItem.Img_url,
                        IsFolder     = true,
                        DefaultImage = "defaultArtistBig.png",
                        Tag          = newentry
                    };
                    res.Items.Add(listItem);
                }
            }

            if (entry.GetValue("special") == "2")
            {
                res.Title = "Artists/" + Translation.ByTags;
                foreach (string[] strings in ArtistManager.Instance.GetTags())
                {
                    SiteItemEntry newentry = new SiteItemEntry();
                    newentry.Provider = this.Name;
                    newentry.SetValue("letter", "true");
                    newentry.SetValue("special", "3");
                    newentry.SetValue("tag", strings[0]);
                    res.ItemType = ItemType.Item;
                    GenericListItem listItem = new GenericListItem()
                    {
                        Title    = strings[0],
                        IsFolder = true,
                        Title2   = strings[1],
                        Tag      = newentry
                    };
                    res.Items.Add(listItem);
                }
            }

            if (entry.GetValue("special") == "3")
            {
                res.Title = "Artists/" + Translation.ByTags + "/" + entry.Title;
                foreach (ArtistItem artistItem in ArtistManager.Instance.GetArtistsByTag(entry.GetValue("tag")))
                {
                    SiteItemEntry newentry = new SiteItemEntry();
                    newentry.Provider = this.Name;
                    newentry.SetValue("letter", "false");
                    newentry.SetValue("id", artistItem.Id);
                    newentry.SetValue("name", artistItem.Name);
                    res.ItemType = ItemType.Artist;
                    GenericListItem listItem = new GenericListItem()
                    {
                        Title   = artistItem.Name,
                        LogoUrl =
                            string.IsNullOrEmpty(artistItem.Img_url.Trim()) ? "@" : artistItem.Img_url,
                        IsFolder     = true,
                        DefaultImage = "defaultArtistBig.png",
                        Tag          = newentry
                    };
                    res.Items.Add(listItem);
                }
            }


            if (entry.GetValue("letter") == "false")
            {
                //res = ArtistManager.Instance.Grabber.GetArtistVideosIds(entry.GetValue("id"));
                res.ItemType = ItemType.Video;
                string user = ArtistManager.Instance.Grabber.GetArtistUser(entry.GetValue("id"));
                GenericListItemCollections resart = ArtistManager.Instance.Grabber.GetArtistVideosIds(entry.GetValue("name"));
                YouTubeFeed videos = null;
                try
                {
                    if (!string.IsNullOrEmpty(user))
                    {
                        YouTubeQuery query =
                            new YouTubeQuery(string.Format("http://gdata.youtube.com/feeds/api/users/{0}/uploads", user));
                        query.NumberToRetrieve = 50;
                        videos = Youtube2MP.service.Query(query);
                    }
                }
                catch (Exception exception)
                {
                    Log.Error(exception);
                }
                foreach (GenericListItem genericListItem in resart.Items)
                {
                    YouTubeEntry tubeEntry   = genericListItem.Tag as YouTubeEntry;
                    YouTubeEntry searchEntry = GetVideFromFeed(Youtube2MP.GetVideoId(tubeEntry), videos);
                    if (searchEntry != null)
                    {
                        searchEntry.Title.Text = tubeEntry.Title.Text;
                        res.Items.Add(Youtube2MP.YouTubeEntry2ListItem(searchEntry));
                    }
                    else
                    {
                        res.Items.Add(genericListItem);
                    }
                }
                res.FolderType = 1;
                res.Title      = "Artists/" + ArtistManager.Instance.GetArtistsById(entry.GetValue("id")).Name;
            }
            return(res);
        }
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();
              string query = YouTubeQuery.TopRatedVideo;
              bool usetime = true;
              res.Title = entry.Title;
              switch (Convert.ToInt32(entry.GetValue("feedint")))
              {
            case 0:
              query = YouTubeQuery.MostViewedVideo;
              break;
            case 1:
              query = YouTubeQuery.TopRatedVideo;
              break;
            case 2:
              query = YouTubeQuery.RecentlyFeaturedVideo;
              break;
            case 3:
              query = YouTubeQuery.MostDiscussedVideo;
              break;
            case 4:
              query = YouTubeQuery.FavoritesVideo;
              break;
            case 5:
              usetime = false;
              query = YouTubeQuery.MostLinkedVideo;
              break;
            case 6:
              usetime = false;
              query = YouTubeQuery.MostRespondedVideo;
              break;
            case 7:
              usetime = false;
              query = YouTubeQuery.MostRecentVideo;
              break;
            case 8:
              usetime = false;
              query = YouTubeQuery.StandardFeeds + "most_shared";
              break;
            case 9:
              usetime = false;
              query = YouTubeQuery.StandardFeeds + "on_the_web";
              break;

              }

              if (!string.IsNullOrEmpty(entry.GetValue("region")))
              {
            string reg = Youtube2MP._settings.Regions[entry.GetValue("region")];
            if (!string.IsNullOrEmpty(reg))
              query = query.Replace("standardfeeds", "standardfeeds/" + reg);
              }

              if (Youtube2MP._settings.MusicFilter)
            query += "_Music";

              YouTubeQuery tubeQuery = new YouTubeQuery(query);
              tubeQuery.NumberToRetrieve = Youtube2MP.ITEM_IN_LIST;
              tubeQuery.StartIndex = entry.StartItem;
              tubeQuery.SafeSearch = YouTubeQuery.SafeSearchValues.None;
              if (!string.IsNullOrEmpty(entry.GetValue("hd")) && entry.GetValue("hd") == "true")
              {
            tubeQuery.ExtraParameters = "hd=true";
              }

              if (usetime)
              {
            if (entry.GetValue("time") == "Today")
              tubeQuery.Time = YouTubeQuery.UploadTime.Today;
            if (entry.GetValue("time") == "This Week")
              tubeQuery.Time = YouTubeQuery.UploadTime.ThisWeek;
            if (entry.GetValue("time") == "This Month")
              tubeQuery.Time = YouTubeQuery.UploadTime.ThisMonth;
              }
              if (entry.StartItem > 1)
            res.Paged = true;
              YouTubeFeed videos = Youtube2MP.service.Query(tubeQuery);
              foreach (YouTubeEntry youTubeEntry in videos.Entries)
              {
            res.Items.Add(Youtube2MP.YouTubeEntry2ListItem(youTubeEntry));
              }

              res.Add(Youtube2MP.GetPager(entry, videos));
              res.FolderType = 1;
              res.ItemType = ItemType.Video;
              return res;
        }
        public GenericListItemCollections GetTopPlayed(int numPlay)
        {
            GenericListItemCollections res = new GenericListItemCollections();
              try
              {
            string lsSQL =
              string.Format(
            "select * from (SELECT VIDEOS.VIDEO_ID AS VIDEO_ID, ARTIST_ID, TITLE, IMG_URL, count(PLAY_HISTORY.VIDEO_ID) as num_play FROM VIDEOS, PLAY_HISTORY WHERE VIDEOS.VIDEO_ID=PLAY_HISTORY.VIDEO_ID group by VIDEOS.VIDEO_ID, ARTIST_ID, TITLE, IMG_URL order by count(PLAY_HISTORY.VIDEO_ID) desc)where num_play>" +
            numPlay.ToString());
            SQLiteResultSet loResultSet = m_db.Execute(lsSQL);
            for (int iRow = 0; iRow < loResultSet.Rows.Count; iRow++)
            {
              YouTubeEntry youTubeEntry = new YouTubeEntry();

              youTubeEntry.AlternateUri = new AtomUri("http://www.youtube.com/watch?v=" + DatabaseUtility.Get(loResultSet, iRow, "VIDEO_ID"));
              youTubeEntry.Title = new AtomTextConstruct();
              youTubeEntry.Title.Text = DatabaseUtility.Get(loResultSet, iRow, "TITLE");
              youTubeEntry.Media = new MediaGroup();
              youTubeEntry.Media.Description = new MediaDescription("");
              youTubeEntry.Id = new AtomId(youTubeEntry.AlternateUri.Content);
              GenericListItem listItem = new GenericListItem()
              {
            Title = youTubeEntry.Title.Text,
            IsFolder = false,
            LogoUrl = DatabaseUtility.Get(loResultSet, iRow, "IMG_URL"),
            Tag = youTubeEntry,
            Title2 = DatabaseUtility.Get(loResultSet, iRow, "num_play"),
            //ParentTag = artistItem
              };
              res.Items.Add(listItem);
            };

              }
              catch (Exception exception)
              {
            Log.Error(exception);
              }
              return res;
        }
Ejemplo n.º 48
0
        public GenericListItemCollections GetArtistVideosIds(string artist_name)
        {
            string site = DownloadArtistInfo(artist_name);

            GetSimilarArtistsSite(site);
            string playlist_id = null;

            try
            {
                Regex regexObj = new Regex("data-list_id=\"(?<name>.*?)\"", RegexOptions.Singleline);
                playlist_id = regexObj.Match(site).Groups["name"].Value;
            }
            catch (ArgumentException ex)
            {
                // Syntax error in the regular expression
            }
            site = DownloadString(string.Format("http://www.youtube.com/playlist?list={0}", playlist_id));

            GenericListItemCollections res = new GenericListItemCollections();

            try
            {
                //------------------------------
                //string img = Regex.Match(site, "<img class=\"artist-image\" src=\"(?<url>.*?)\" />", RegexOptions.Singleline).Groups["url"].Value;
                //ArtistItem artistItem = ArtistManager.Instance.GetArtistsById(artist_id);
                //artistItem.Img_url = img;
                //ArtistManager.Instance.Save(artistItem);
                //----------------------------
                //@"<li class=""playlist-video-item.*?<a href=""/watch\?v=(?<vid_id>.*?)&.*?data-thumb=""(?<thumb>.*?)"".*?<span class=""video-time"">(?<duration>.*?)</span>"

                //Regex regexObj = new Regex("album-row.*?data-video-ids=\"(?<vid_id>.*?)\".*?<span class=\"clip\"><img src=\"(?<thumb>.*?)\".*?album-track-name\">(?<title>.*?)</span>", RegexOptions.Singleline);
                Regex regexObj    = new Regex(@"playlist-video-item.*?<a href=""/watch\?v=(?<vid_id>.*?)&.*?data-thumb=""(?<thumb>.*?)"".*?<span class=""video-time"">(?<duration>.*?)</span>.*?video-title ""  dir=""ltr"">(?<title>.*?)</span>", RegexOptions.Singleline);
                Match matchResult = regexObj.Match(site);
                while (matchResult.Success)
                {
                    YouTubeEntry youTubeEntry = new YouTubeEntry();

                    youTubeEntry.AlternateUri      = new AtomUri("http://www.youtube.com/watch?v=" + matchResult.Groups["vid_id"].Value);
                    youTubeEntry.Title             = new AtomTextConstruct();
                    youTubeEntry.Title.Text        = HttpUtility.HtmlDecode(matchResult.Groups["title"].Value);
                    youTubeEntry.Media             = new MediaGroup();
                    youTubeEntry.Media.Description = new MediaDescription("");
                    youTubeEntry.Id = new AtomId(youTubeEntry.AlternateUri.Content);
                    GenericListItem listItem = new GenericListItem()
                    {
                        Title    = youTubeEntry.Title.Text,
                        IsFolder = false,
                        LogoUrl  = "http:" + matchResult.Groups["thumb"].Value.Replace("default.jpg", "hqdefault.jpg"),
                        Tag      = youTubeEntry,
                        Title2   = matchResult.Groups["duration"].Value,
                        //ParentTag = artistItem
                    };
                    res.Items.Add(listItem);
                    //resultList.Add(matchResult.Groups["groupname"].Value);
                    matchResult = matchResult.NextMatch();
                }
            }
            catch (Exception ex)
            {
                // Syntax error in the regular expression
            }
            res.ItemType = ItemType.Video;
            return(res);
        }
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();
              if (entry.GetValue("letter") == "")
              {
            {
              res.Title = "Artists";
              SiteItemEntry newentry1 = new SiteItemEntry();
              newentry1.Provider = this.Name;
              newentry1.SetValue("letter", "true");
              newentry1.SetValue("special", "1");
              newentry1.Title = Translation.PlayedArtists;
              GenericListItem listItem1 = new GenericListItem()
                                        {
                                          Title = Translation.PlayedArtists,
                                          IsFolder = true,
                                          Tag = newentry1
                                        };
              res.Items.Add(listItem1);
            }

            {
              res.Title = "Artists";
              SiteItemEntry newentry1 = new SiteItemEntry();
              newentry1.Provider = this.Name;
              newentry1.SetValue("letter", "true");
              newentry1.SetValue("special", "2");
              newentry1.Title = Translation.ByTags;
              GenericListItem listItem1 = new GenericListItem()
              {
            Title = Translation.ByTags,
            IsFolder = true,
            Tag = newentry1
              };
              res.Items.Add(listItem1);
            }

            foreach (string letter in ArtistManager.Instance.GetArtistsLetters())
            {
              SiteItemEntry newentry = new SiteItemEntry();
              newentry.Provider = this.Name;
              newentry.SetValue("letter", "true");
              newentry.SetValue("special", "false");
              newentry.Title = letter;
              GenericListItem listItem = new GenericListItem()
                                       {
                                         Title = letter,
                                         IsFolder = true,
                                         Tag = newentry
                                       };
              res.Items.Add(listItem);
            }
              }
              if (entry.GetValue("letter") == "true" && entry.GetValue("special") == "false")
              {
            res.Title = "Artists/Letter/" + entry.Title;
            List<ArtistItem> list = ArtistManager.Instance.GetArtists(entry.Title);
            if (list.Count > 500)
            {
              foreach (string letter in ArtistManager.Instance.GetArtistsLetters(entry.Title))
              {
            SiteItemEntry newentry = new SiteItemEntry();
            newentry.Provider = this.Name;
            newentry.SetValue("letter", "true");
            newentry.SetValue("special", "false");
            newentry.Title = letter;
            GenericListItem listItem = new GenericListItem()
            {
              Title = letter,
              IsFolder = true,
              Tag = newentry
            };
            res.Items.Add(listItem);
              }
            }
            else
            {
              foreach (ArtistItem artistItem in list)
              {
            SiteItemEntry newentry = new SiteItemEntry();
            newentry.Provider = this.Name;
            newentry.SetValue("letter", "false");
            newentry.SetValue("id", artistItem.Id);
            newentry.SetValue("name", artistItem.Name);
            res.ItemType = ItemType.Artist;
            GenericListItem listItem = new GenericListItem()
                                         {
                                           Title = artistItem.Name,
                                           LogoUrl =
                                             string.IsNullOrEmpty(artistItem.Img_url.Trim()) ? "@" : artistItem.Img_url,
                                           IsFolder = true,
                                           DefaultImage = "defaultArtistBig.png",
                                           Tag = newentry
                                         };
            res.Items.Add(listItem);
              }
            }
              }
              if (entry.GetValue("special") == "1")
              {
            res.Title = "Artists/" + Translation.PlayedArtists;
            foreach (
              ArtistItem artistItem in
            ArtistManager.Instance.GetArtistsByIds(DatabaseProvider.InstanInstance.GetPlayedArtistIds(1)))
            {
              SiteItemEntry newentry = new SiteItemEntry();
              newentry.Provider = this.Name;
              newentry.SetValue("letter", "false");
              newentry.SetValue("id", artistItem.Id);
              newentry.SetValue("name", artistItem.Name);
              res.ItemType = ItemType.Artist;
              GenericListItem listItem = new GenericListItem()
                                       {
                                         Title = artistItem.Name,
                                         LogoUrl =
                                           string.IsNullOrEmpty(artistItem.Img_url.Trim()) ? "@" : artistItem.Img_url,
                                         IsFolder = true,
                                         DefaultImage = "defaultArtistBig.png",
                                         Tag = newentry
                                       };
              res.Items.Add(listItem);
            }
              }

              if (entry.GetValue("special") == "2")
              {
            res.Title = "Artists/" + Translation.ByTags;
            foreach (string[] strings in ArtistManager.Instance.GetTags())
            {
              SiteItemEntry newentry = new SiteItemEntry();
              newentry.Provider = this.Name;
              newentry.SetValue("letter", "true");
              newentry.SetValue("special", "3");
              newentry.SetValue("tag",strings[0]);
              res.ItemType = ItemType.Item;
              GenericListItem listItem = new GenericListItem()
              {
            Title = strings[0],
            IsFolder = true,
            Title2 = strings[1],
            Tag = newentry
              };
              res.Items.Add(listItem);
            }
              }

              if (entry.GetValue("special") == "3")
              {
            res.Title = "Artists/" + Translation.ByTags + "/" + entry.Title;
            foreach (ArtistItem artistItem in ArtistManager.Instance.GetArtistsByTag(entry.GetValue("tag")))
            {
              SiteItemEntry newentry = new SiteItemEntry();
              newentry.Provider = this.Name;
              newentry.SetValue("letter", "false");
              newentry.SetValue("id", artistItem.Id);
              newentry.SetValue("name", artistItem.Name);
              res.ItemType = ItemType.Artist;
              GenericListItem listItem = new GenericListItem()
              {
            Title = artistItem.Name,
            LogoUrl =
              string.IsNullOrEmpty(artistItem.Img_url.Trim()) ? "@" : artistItem.Img_url,
            IsFolder = true,
            DefaultImage = "defaultArtistBig.png",
            Tag = newentry
              };
              res.Items.Add(listItem);
            }
              }

              if (entry.GetValue("letter") == "false")
              {
            //res = ArtistManager.Instance.Grabber.GetArtistVideosIds(entry.GetValue("id"));
            res.ItemType = ItemType.Video;
            string user = ArtistManager.Instance.Grabber.GetArtistUser(entry.GetValue("id"));
            GenericListItemCollections resart = ArtistManager.Instance.Grabber.GetArtistVideosIds(entry.GetValue("name"));
            YouTubeFeed videos = null;
            try
            {
              if (!string.IsNullOrEmpty(user))
              {
            YouTubeQuery query =
              new YouTubeQuery(string.Format("http://gdata.youtube.com/feeds/api/users/{0}/uploads", user));
            query.NumberToRetrieve = 50;
            videos = Youtube2MP.service.Query(query);
              }
            }
            catch (Exception exception)
            {
              Log.Error(exception);
            }
            foreach (GenericListItem genericListItem in resart.Items)
            {
              YouTubeEntry tubeEntry = genericListItem.Tag as YouTubeEntry;
              YouTubeEntry searchEntry = GetVideFromFeed(Youtube2MP.GetVideoId(tubeEntry), videos);
              if (searchEntry != null)
              {
            searchEntry.Title.Text = tubeEntry.Title.Text;
            res.Items.Add(Youtube2MP.YouTubeEntry2ListItem(searchEntry));
              }
              else
              {
            res.Items.Add(genericListItem);
              }
            }
            res.FolderType = 1;
            res.Title = "Artists/" + ArtistManager.Instance.GetArtistsById(entry.GetValue("id")).Name;
              }
              return res;
        }
Ejemplo n.º 50
0
        public GenericListItemCollections GetList(SiteItemEntry entry)
        {
            GenericListItemCollections res = new GenericListItemCollections();
            YouTubeQuery query             = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);

            query.Query            = entry.GetValue("term");
            query.NumberToRetrieve = Youtube2MP.ITEM_IN_LIST;
            query.StartIndex       = entry.StartItem;
            if (entry.StartItem > 1)
            {
                res.Paged = true;
            }
            query.OrderBy = "relevance";

            if (Youtube2MP._settings.MusicFilter)
            {
                query.Categories.Add(new QueryCategory("Music", QueryCategoryOperator.AND));
            }

            if (!string.IsNullOrEmpty(entry.GetValue("sortint")))
            {
                switch (Convert.ToInt32(entry.GetValue("sortint")))
                {
                case 0:
                    query.OrderBy = "relevance";
                    break;

                case 1:
                    query.OrderBy = "published";
                    break;

                case 2:
                    query.OrderBy = "viewCount";
                    break;

                case 3:
                    query.OrderBy = "rating";
                    break;
                }
            }

            if (entry.GetValue("time") == "Today")
            {
                query.Time = YouTubeQuery.UploadTime.Today;
            }
            if (entry.GetValue("time") == "This Week")
            {
                query.Time = YouTubeQuery.UploadTime.ThisWeek;
            }
            if (entry.GetValue("time") == "This Month")
            {
                query.Time = YouTubeQuery.UploadTime.ThisMonth;
            }

            YouTubeFeed videos = Youtube2MP.service.Query(query);

            res.Title = Translation.Search + "/" + entry.GetValue("term");
            foreach (YouTubeEntry youTubeEntry in videos.Entries)
            {
                res.Items.Add(Youtube2MP.YouTubeEntry2ListItem(youTubeEntry));
            }
            res.FolderType = 1;
            res.ItemType   = ItemType.Video;
            res.Add(Youtube2MP.GetPager(entry, videos));
            return(res);
        }