public YTItemInfo(ID itemID, ID templateID, string name, YouTubeEntry entry)
 {
     ItemID = itemID;
      TemplateID = templateID;
      Name = name;
      YouTubeItem = entry;
 }
        public void NowPlaying(YouTubeEntry song)
        {
            if (!IsLoged)
            return;
              try
              {
            string Artist = string.Empty;
            string Title = string.Empty;
            int length = 0;
            string _title = song.Title.Text;
            if (_title.Contains("-"))
            {
              Artist = _title.Split('-')[0].Trim();
              Title = _title.Split('-')[1].Trim();
            }
            if (song.Duration != null && song.Duration.Seconds != null)
            {
              length = Convert.ToInt32(song.Duration.Seconds, 10);
            }

            if (!string.IsNullOrEmpty(Artist) && !string.IsNullOrEmpty(Title) && length > 0)
            {
              NowplayingTrack track1 = new NowplayingTrack(Artist, Title, new TimeSpan(0, 0, length));
              manager.ReportNowplaying(track1);
            }
              }
              catch (Exception exception)
              {
            Log.Error(exception);
              }
        }
		protected void ExecuteUpload(IExecuteYouTubeUploaderWorkflowMessage message, ClientLoginAuthenticator youTubeAuthenticator, YouTubeEntry youTubeEntry)
		{
			var cancellationTokenSource = new CancellationTokenSource();
			var cancellationToken = cancellationTokenSource.Token;

			var task = Task.Factory.StartNew(()=>{});
			task.ContinueWith((t) =>
				{
					if (!cancellationToken.IsCancellationRequested)
					{
						YouTubeUploaderService.Uploaders.Add(message, new CancellableTask
						{
							Task = task,
							CancellationTokenSource = cancellationTokenSource
						});

						var resumableUploader = new ResumableUploader(message.Settings.Upload.ChunkSize);
						resumableUploader.AsyncOperationCompleted += OnResumableUploaderAsyncOperationCompleted;
						resumableUploader.AsyncOperationProgress += OnResumableUploaderAsyncOperationProgress;

						cancellationToken.Register(() => resumableUploader.CancelAsync(message));
						resumableUploader.InsertAsync(youTubeAuthenticator, youTubeEntry, message);
					}
					cancellationToken.ThrowIfCancellationRequested();
				}
				, cancellationToken);
		}
 public void MediaTest()
 {
     YouTubeEntry target = new YouTubeEntry(); // TODO: Initialize to an appropriate value
     GData.YouTube.MediaGroup expected = new GData.YouTube.MediaGroup();
     GData.YouTube.MediaGroup actual;
     target.Media = expected;
     actual = target.Media;
     Assert.AreEqual(expected, actual);
 }
        /// <summary>
        /// upload a new video to this users youtube account
        /// </summary>
        /// <param name="userName">the username (account) to use</param>
        /// <param name="entry">the youtube entry</param>
        /// <returns></returns>
        public YouTubeEntry Upload(string userName, YouTubeEntry entry)
        {
            if (String.IsNullOrEmpty(userName))
            {
                userName = "******";
            }
            Uri uri = new Uri("http://uploads.gdata.youtube.com/feeds/api/users/" + userName + "/uploads");

            return(base.Insert(uri, entry));
        }
 public void Submit(YouTubeEntry song)
 {
     try
     {
         Lastfm.Scrobbling.Entry track = new Lastfm.Scrobbling.Entry("madonna", "test", DateTime.Now, Lastfm.Scrobbling.PlaybackSource.User, new TimeSpan(0, 2, 32), Lastfm.Scrobbling.ScrobbleMode.Played);
         manager.Queue(track);
         //manager.Submit();
     }
     catch
     {
     }
 }
 public static Video MapYouTubeVideo(G.YouTubeEntry videoEntry)
 {
     return(new Video
     {
         ID = videoEntry.VideoId,
         ThumbnailUri = new Uri(videoEntry.Media.Thumbnails[0].Url),
         EmbedHtml = String.Format(YouTubeConfiguration.Settings.Embedding.HtmlTemplate, videoEntry.VideoId),
         Title = videoEntry.Title.Text,
         Description = videoEntry.Media.Description.Value,
         PositionDateTime = videoEntry.Published,
         Position = videoEntry.Location == null ? null : new Position(videoEntry.Location.Latitude, videoEntry.Location.Longitude)
     });
 }
Пример #8
0
    protected void SubmitVideo_ServerClick(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty(this.Title.Text) == false &&
            String.IsNullOrEmpty(this.Description.Text) == false &&
            String.IsNullOrEmpty(this.Category.SelectedValue) == false &&
            String.IsNullOrEmpty(this.Keyword.Text) == false)
        {

            GAuthSubRequestFactory authFactory = new GAuthSubRequestFactory(ServiceNames.YouTube, "TesterApp");

            YouTubeService service = new YouTubeService(authFactory.ApplicationName,
                "ytapi-FrankMantek-TestaccountforGD-sjgv537n-0",
                "AI39si4v3E6oIYiI60ndCNDqnPP5lCqO28DSvvDPnQt-Mqia5uPz2e4E-gMSBVwHXwyn_LF1tWox4LyM-0YQd2o4i_3GcXxa2Q"
                );

            authFactory.Token = HttpContext.Current.Session["token"] as string;
            service.RequestFactory = authFactory;

            try
            {
                YouTubeEntry entry = new YouTubeEntry();
                
                entry.Media = new Google.GData.YouTube.MediaGroup();
                entry.Media.Description = new MediaDescription(this.Description.Text);
                entry.Media.Title = new MediaTitle(this.Title.Text);
                entry.Media.Keywords = new MediaKeywords(this.Keyword.Text);

                // entry.Media.Categories
                MediaCategory category = new MediaCategory(this.Category.SelectedValue);
                category.Attributes["scheme"] = YouTubeService.DefaultCategory;

                entry.Media.Categories.Add(category);
                FormUploadToken token = service.FormUpload(entry);
                HttpContext.Current.Session["form_upload_url"] = token.Url;
                HttpContext.Current.Session["form_upload_token"] = token.Token;
                string page = "http://" + Request.ServerVariables["SERVER_NAME"];
                if (Request.ServerVariables["SERVER_PORT"] != "80")
                {
                    page += ":" + Request.ServerVariables["SERVER_PORT"];
                }
                page += Request.ServerVariables["URL"];

                HttpContext.Current.Session["form_upload_redirect"] = page;
                Response.Redirect("UploadVideo.aspx");
            }
            catch (GDataRequestException gdre)
            {
                HttpWebResponse response = (HttpWebResponse)gdre.Response;
            }
        }
    }
        public void NowPlaying(YouTubeEntry song)
        {
            try
            {
                Lastfm.Scrobbling.NowplayingTrack track = new Lastfm.Scrobbling.NowplayingTrack("madonna", "test");
                track.Album = "valami";
                track.Duration = new TimeSpan(0, 3, 22);
                manager.ReportNowplaying(track);

            }
            catch
            {
            }
        }
Пример #10
0
        /// <summary>
        /// Method for browser-based upload, gets back a non-Atom response
        /// </summary>
        /// <param name="newEntry">The YouTubeEntry containing the metadata for a video upload</param>
        /// <returns>A FormUploadToken object containing an upload token and POST url</returns>
        public FormUploadToken FormUpload(YouTubeEntry newEntry)
        {
            if (newEntry == null)
            {
                throw new ArgumentNullException("newEntry");
            }

            Uri             uri          = new Uri("https://gdata.youtube.com/action/GetUploadToken");
            Stream          returnStream = EntrySend(uri, newEntry, GDataRequestType.Insert);
            FormUploadToken token        = new FormUploadToken(returnStream);

            returnStream.Close();

            return(token);
        }
Пример #11
0
        public static Video CreateVideo(YouTubeEntry youTubeEntry)
        {
            var video = new Video();

            video.Title = youTubeEntry.Title.Text;
            video.Description = String.Format("Duration: {0}", youTubeEntry.Duration.IntegerValue);
            video.Url = youTubeEntry.AlternateUri.ToString();
            video.TimeStamp = youTubeEntry.Published;
            video.Id = youTubeEntry.VideoId;

            var tags = (from c in youTubeEntry.Categories
                        select c.Term.ToLower().Trim().Replace("http://gdata.youtube.com/schemas/2007#", String.Empty)).ToArray();

            video.SetTags(tags);

            return video;
        }
 public ArtistItem GetArtist(YouTubeEntry entry)
 {
     ArtistItem artistItem = new ArtistItem();
       string lsSQL = string.Format("select distinct ARTIST_ID from VIDEOS WHERE VIDEO_ID=\"{0}\" ", Youtube2MP.GetVideoId(entry));
       SQLiteResultSet loResultSet = m_db.Execute(lsSQL);
       for (int iRow = 0; iRow < loResultSet.Rows.Count; iRow++)
       {
     artistItem= ArtistManager.Instance.GetArtistsById(DatabaseUtility.Get(loResultSet, iRow, "ARTIST_ID"));
     break;
       }
       if (string.IsNullOrEmpty(artistItem.Name))
     artistItem.Name = ArtistManager.Instance.GetArtistName(entry.Title.Text);
       ArtistItem artistItemLocal = GetArtistsByName(artistItem.Name);
       if (artistItemLocal != null)
       {
     artistItem.Bio = artistItemLocal.Bio;
     artistItem.Id = string.IsNullOrEmpty(artistItem.Id) ? artistItemLocal.Id : artistItem.Id;
     artistItem.Img_url = !string.IsNullOrEmpty(artistItemLocal.Img_url) ? artistItemLocal.Img_url : artistItem.Img_url;
     artistItem.Name = string.IsNullOrEmpty(artistItem.Name) ? artistItemLocal.Name : artistItem.Name;
     artistItem.Tags = string.IsNullOrEmpty(artistItem.Tags) ? artistItemLocal.Tags : artistItem.Tags;
     artistItem.User = string.IsNullOrEmpty(artistItem.User) ? artistItemLocal.User : artistItem.User;
       }
       return artistItem;
 }
 public static Song YoutubeEntry2Song(YouTubeEntry en)
 {
     Song song = new Song();
       string title = en.Title.Text;
       if (title.Contains("-"))
       {
     song.Artist = title.Split('-')[0].Trim();
     song.Title = title.Split('-')[1].Trim();
       }
       else
     song.Artist = title;
       song.FileName = PlaybackUrl(en);
       if (en.Media.Content != null)
       {
     song.Duration = Convert.ToInt32(en.Media.Content.Attributes["duration"].ToString(), 10);
       }
       return song;
 }
Пример #14
0
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a test on the YouTube Feed object</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void YouTubeRatingsTest()
        {
            Tracing.TraceMsg("Entering YouTubeRatingsTest");

            YouTubeService service = new YouTubeService("NETUnittests", this.ytClient, this.ytDevKey);
            if (this.userName != null)
            {
                service.Credentials = new GDataCredentials(this.ytUser, this.ytPwd);
            }

            YouTubeEntry entry = new YouTubeEntry();

            entry.MediaSource = new MediaFileSource(this.resourcePath + "test_movie.mov", "video/quicktime");
            entry.Media = new YouTube.MediaGroup();
            entry.Media.Description = new MediaDescription("This is a test");
            entry.Media.Title = new MediaTitle("Sample upload");
            entry.Media.Keywords = new MediaKeywords("math");

            // entry.Media.Categories

            MediaCategory category = new MediaCategory("Nonprofit");
            category.Attributes["scheme"] = YouTubeService.DefaultCategory;

            entry.Media.Categories.Add(category);

            YouTubeEntry newEntry = service.Upload(this.ytUser, entry);

            Assert.AreEqual(newEntry.Media.Description.Value, entry.Media.Description.Value, "Description should be equal");
            Assert.AreEqual(newEntry.Media.Keywords.Value, entry.Media.Keywords.Value, "Keywords should be equal");


            Rating rating = new Rating();
            rating.Value = 1;
            newEntry.Rating = rating;

            YouTubeEntry ratedEntry = newEntry.Update();
            ratedEntry.Delete();
        }
Пример #15
0
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a test on the YouTube Feed object</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void YouTubeInsertTest()
        {
            Tracing.TraceMsg("Entering YouTubeFeedTest");

            YouTubeService service = new YouTubeService("NETUnittests", this.ytClient, this.ytDevKey);
            if (this.userName != null)
            {
                service.Credentials = new GDataCredentials(this.ytUser, this.ytPwd);
            }

            GDataRequestFactory factory = service.RequestFactory as GDataRequestFactory;
            factory.Timeout = 1000000; 

            YouTubeEntry entry = new YouTubeEntry();

            entry.MediaSource = new MediaFileSource(this.resourcePath + "test_movie.mov", "video/quicktime");
            entry.Media = new YouTube.MediaGroup();
            entry.Media.Description = new MediaDescription("This is a test with and & in it");
            entry.Media.Title = new MediaTitle("Sample upload");
            entry.Media.Keywords = new MediaKeywords("math");

            // entry.Media.Categories

            MediaCategory category = new MediaCategory("Nonprofit");
            category.Attributes["scheme"] = YouTubeService.DefaultCategory;

            entry.Media.Categories.Add(category);

            YouTubeEntry newEntry = service.Upload(this.ytUser, entry);

            Assert.AreEqual(newEntry.Media.Description.Value, entry.Media.Description.Value, "Description should be equal");
            Assert.AreEqual(newEntry.Media.Keywords.Value, entry.Media.Keywords.Value, "Keywords should be equal");

            // now change the entry

            newEntry.Title.Text = "This test upload will soon be deleted";
            YouTubeEntry anotherEntry = newEntry.Update() as YouTubeEntry;

            // bugbug in YouTube server. Returns empty category that the service DOES not like on reuse. so remove
            ExtensionList a = ExtensionList.NotVersionAware();
            foreach (MediaCategory m in anotherEntry.Media.Categories)
            {
                if (String.IsNullOrEmpty(m.Value))
                {
                    a.Add(m);
                }
            }

            foreach (MediaCategory m in a)
            {
                anotherEntry.Media.Categories.Remove(m);
            }

            Assert.AreEqual(newEntry.Media.Description.Value, anotherEntry.Media.Description.Value, "Description should be equal");
            Assert.AreEqual(newEntry.Media.Keywords.Value, anotherEntry.Media.Keywords.Value, "Keywords should be equal");

            // now update the video
            anotherEntry.MediaSource = new MediaFileSource(this.resourcePath + "test.mp4", "video/mp4");
            anotherEntry.Update();


            // now delete the guy again

            newEntry.Delete();
        }
        public void AddItemToPlayList(YouTubeEntry vid, ref PlayList playList)
        {
            if (playList == null || vid == null)
                return;
            string PlayblackUrl = "";

            GUIListItem pItem = new GUIListItem(vid.Title.Text);
            pItem.MusicTag = vid;
            try
            {
                pItem.Duration = Convert.ToInt32(vid.Duration.Seconds);
            }
            catch (Exception)
            {
            }

            try
            {
                PlayblackUrl = vid.AlternateUri.ToString();
                if (vid.Media != null && vid.Media.Contents != null && vid.Media.Contents.Count > 0)
                {
                    PlayblackUrl = string.Format("http://www.youtube.com/v/{0}", Youtube2MP.getIDSimple(vid.Id.AbsoluteUri));
                }
            }
            catch (Exception)
            {
                return;
            }

            VideoInfo qa = new VideoInfo();
            PlayListItem playlistItem = new PlayListItem();
            playlistItem.Type = PlayListItem.PlayListItemType.VideoStream;
                // Playlists.PlayListItem.PlayListItemType.Audio;
            qa.Entry = vid;
            playlistItem.FileName = PlayblackUrl;
            playlistItem.Description = pItem.Label;
            playlistItem.Duration = pItem.Duration;
            playlistItem.MusicTag = qa;
            playList.Add(playlistItem);
        }
        public VideoInfo SelectQuality(YouTubeEntry vid)
        {
            VideoInfo info = new VideoInfo();
              info.Get(Youtube2MP.getIDSimple(vid.AlternateUri.Content));
              if (!string.IsNullOrEmpty(info.Reason))
              {
            Err_message(info.Reason);
            info.Quality = VideoQuality.Unknow;
            return info;
              }

              switch (Youtube2MP._settings.VideoQuality)
              {
            case 0:
              info.Quality = VideoQuality.Normal;
              break;
            case 1:
              info.Quality = VideoQuality.High;
              break;
            case 2:
              info.Quality = VideoQuality.HD;
              break;
            case 3:
              info.Quality = VideoQuality.FullHD;
              break;
            case 4:
              {
            string title = vid.Title.Text;
            if (info.FmtMap.Contains("18"))
              info.Quality = VideoQuality.High;
            if (info.FmtMap.Contains("22"))
              info.Quality = VideoQuality.HD;
            if (info.FmtMap.Contains("37"))
              info.Quality = VideoQuality.FullHD;
            break;
              }
            case 5:
              {
            GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
            if (dlg == null) info.Quality = VideoQuality.Normal;
            dlg.Reset();
            dlg.SetHeading("Select video quality");
            dlg.Add("Normal quality");
            dlg.Add("High quality");
            if (info.FmtMap.Contains("22/"))
            {
              dlg.Add("HD quality");
            }
            if (info.FmtMap.Contains("37"))
            {
              dlg.Add("Full HD quality");
            }
            dlg.DoModal(GetID);
            if (dlg.SelectedId == -1) info.Quality = VideoQuality.Unknow;
            switch (dlg.SelectedLabel)
            {
              case 0:
                info.Quality = VideoQuality.Normal;
                break;
              case 1:
                info.Quality = VideoQuality.High;
                break;
              case 2:
                info.Quality = VideoQuality.HD;
                break;
              case 3:
                info.Quality = VideoQuality.FullHD;
                break;
            }
              }
              break;
              }
              return info;
        }
Пример #18
0
 internal virtual YouTubeBaseEntry CreateYouTubeBaseEntry()
 {
     // TODO: Instantiate an appropriate concrete class.
     YouTubeBaseEntry target = new YouTubeEntry();
     return target;
 }
Пример #19
0
 public MyYouTubeEntry(YouTubeEntry entry)
 {
     YouTubeEntry = entry;
 }
        public void Submit(YouTubeEntry song)
        {
            if (!IsLoged)
            return;
              try
              {
            string Artist = string.Empty;
            string Title = string.Empty;
            int length = 0;
            string _title = song.Title.Text;
            if (_title.Contains("-"))
            {
              Artist = _title.Split('-')[0].Trim();
              Title = _title.Split('-')[1].Trim();
            }
            if (song.Duration != null && song.Duration.Seconds != null)
            {
              length = Convert.ToInt32(song.Duration.Seconds, 10);
            }

            if (!string.IsNullOrEmpty(Artist) && !string.IsNullOrEmpty(Title) && length > 0)
            {
              Entry entry = new Entry(Artist, Title, DateTime.Now, PlaybackSource.User, new TimeSpan(0, 0, length), ScrobbleMode.Played);
              manager.Queue(entry);
              //manager.Submit();
            }
              }
              catch (Exception exception)
              {
            Log.Error(exception);
              }
        }
 /// <summary>
 /// upload a new video to the default/authenticated account
 /// </summary>
 /// <param name="entry">the youtube entry</param>
 /// <returns></returns>
 public YouTubeEntry Upload(YouTubeEntry entry)
 {
     return Upload(null, entry);
 }
        public void DoPlay(YouTubeEntry vid, bool fullscr, GUIListControl facade)
        {
            if (vid != null)
            {
            VideoInfo qa = SelectQuality(vid);
            if (qa.Quality == VideoQuality.Unknow)
                return;
            Youtube2MP.temp_player.Reset();
            Youtube2MP.temp_player.RepeatPlaylist = true;

            Youtube2MP.temp_player.CurrentPlaylistType = PlayListType.PLAYLIST_MUSIC_VIDEO;
            PlayList playlist = Youtube2MP.temp_player.GetPlaylist(PlayListType.PLAYLIST_MUSIC_VIDEO);
            playlist.Clear();
            g_Player.PlayBackStopped += new g_Player.StoppedHandler(g_Player_PlayBackStopped);
            AddItemToPlayList(vid, ref playlist, qa);

            if (facade != null)
            {
                qa.Items = new Dictionary<string, string>();
                int selected = facade.SelectedListItemIndex ;
                for (int i = selected + 1; i < facade.ListItems.Count; i++)
                {
                    AddItemToPlayList(facade.ListItems[i], ref playlist, new VideoInfo(qa));
                }
            }

            PlayListPlayer.SingletonPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_NONE;
            Youtube2MP.player.CurrentPlaylistType = PlayListType.PLAYLIST_NONE;
            Youtube2MP.temp_player.Play(0);

            if (g_Player.Playing && fullscr)
            {
                if (_setting.ShowNowPlaying)
                {
                    GUIWindowManager.ActivateWindow(29052);
                }
                else
                {
                    g_Player.ShowFullScreenWindow();
                }
            }

            if (!g_Player.Playing)
            {
                Err_message("Unable to playback the item ! ");
            }
            }
        }
 public bool filterVideoContens(YouTubeEntry vid)
 {
     if (_setting.MusicFilter && _setting.UseExtremFilter)
       {
     if (vid.Title.Text.Contains("-"))
       return true;
     else
       return false;
       }
       return true;
 }
        public static void SetLabels(YouTubeEntry vid, string type)
        {
            ClearLabels(type);
              try
              {
              if (vid.Duration.Seconds!=null)
              {
              int sec = int.Parse(vid.Duration.Seconds);
              int min = sec/60;
              GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.Duration",
                                             string.Format("{0}:{1:0#}", min, (sec - (min*60))));
              }
              GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.PublishDate", vid.Published.ToShortDateString());
              if (vid.Authors != null && vid.Authors.Count > 0)
              GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.Autor", vid.Authors[0].Name);
              if (vid.Rating != null)
              GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.Rating", (vid.Rating.Average*2).ToString());
              if (vid.Statistics != null)
              {
              GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.ViewCount", vid.Statistics.ViewCount);
              GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.WatchCount", vid.Statistics.WatchCount);
              GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.FavoriteCount",
                                             vid.Statistics.FavoriteCount);
              }
            GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.Image", GetLocalImageFileName(GetBestUrl(vid.Media.Thumbnails)));
            GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.Summary", vid.Media.Description.Value);
              }
              catch
              {

              }
              if (vid.Title.Text.Contains("-"))
              {
            GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.Title", vid.Title.Text.Split('-')[1].Trim());
            if (type == "NowPlaying")
            {
              GUIPropertyManager.SetProperty("#Play.Current.Title", vid.Title.Text.Split('-')[1].Trim().Trim());
            }
            GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Artist.Name", vid.Title.Text.Split('-')[0].Trim());
            GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.FanArt", GetFanArtImage(vid.Title.Text.Split('-')[0]).Trim());
              }
              else
              {
            GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.Title", vid.Title.Text);
            GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Artist.Name", " ");
              }
              if (type == "NowPlaying")
              {
            Uri videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + vid.VideoId);
            Video video = Youtube2MP.request.Retrieve<Video>(videoEntryUrl);

            Feed<Comment> comments = Youtube2MP.request.GetComments(video);
            string cm = "";
            foreach (Comment c in comments.Entries)
            {
              cm += c.Content + "\n------------------------------------------\n";
            }
            GUIPropertyManager.SetProperty("#Youtube.fm." + type + ".Video.Comments", cm);
              }
        }
 public static string StreamPlaybackUrl(YouTubeEntry vid, VideoInfo qu)
 {
     //return youtubecatch1(vid.Id.AbsoluteUri);
       string url = youtubecatch1(vid.AlternateUri.Content, qu);
       if (UrlHolder.ContainsKey(vid.Title.Text))
       {
     UrlHolder[vid.Title.Text] = vid;
       }
       else
       {
     UrlHolder.Add(vid.Title.Text, vid);
       }
       return url;
 }
        public void AddItemToPlayList(YouTubeEntry vid, ref PlayList playList, VideoInfo qa)
        {
            if (playList == null || vid == null)
            return;
            string PlayblackUrl = "";

            List<GUIListItem> list = new List<GUIListItem>();

            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 = vid.Title.Text;
            try
            {
                playlistItem.Duration = Convert.ToInt32(vid.Duration.Seconds, 10);
            }
            catch
            {

            }
            playlistItem.MusicTag = qa;
            playList.Add(playlistItem);
            }
        }
 /// <summary>
 /// upload a new video to the default/authenticated account
 /// </summary>
 /// <param name="entry">the youtube entry</param>
 /// <returns></returns>
 public YouTubeEntry Upload(YouTubeEntry entry)
 {
     return(Upload(null, entry));
 }
 public void LocationTest()
 {
     YouTubeEntry target = new YouTubeEntry(); // TODO: Initialize to an appropriate value
     GeoRssWhere expected = new GeoRssWhere(10, 11);
     GeoRssWhere actual;
     target.Location = expected;
     actual = target.Location;
     Assert.AreEqual(expected, actual);
 }
Пример #29
0
 protected virtual void VideoAdded(YouTubeEntry video)
 {
     if (OnVideoAdded != null)
     {
         if (video.Rating == null)
         {
             Rating r = new Rating();
             r.NumRaters = 0;
             r.Average = 0;
             video.Rating = r;
         }
         OnVideoAdded(this, video);
     }
 }
        public static bool YoutubeEntry2Song(string fileurl, ref Song song, ref YouTubeEntry en)
        {
            if (fileurl.Contains("youtube."))
              {
            String videoEntryUrl = "http://gdata.youtube.com/feeds/api/videos/" + getIDSimple(fileurl);
            en = (YouTubeEntry)service.Get(videoEntryUrl);
              }
              if (en == null)
            return false;

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

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

              return true;
        }
 /// <summary>
 /// upload a new video to this users youtube account
 /// </summary>
 /// <param name="userName">the username (account) to use</param>
 /// <param name="entry">the youtube entry</param>
 /// <returns></returns>
 public YouTubeEntry Upload(string userName, YouTubeEntry entry)
 {
     if (String.IsNullOrEmpty(userName))
     {
         userName = "******";
     }
     Uri uri = new Uri("http://uploads.gdata.youtube.com/feeds/api/users/" + userName + "/uploads");
     return base.Insert(uri, entry); 
 }
 public string FormatTitle(YouTubeEntry vid)
 {
     return string.Format("{0}", vid.Title.Text);
 }
        /// <summary>
        /// Method for browser-based upload, gets back a non-Atom response
        /// </summary>
        /// <param name="newEntry">The YouTubeEntry containing the metadata for a video upload</param>
        /// <returns>A FormUploadToken object containing an upload token and POST url</returns>
        public FormUploadToken FormUpload(YouTubeEntry newEntry)
        {
            Uri uri = new Uri("http://gdata.youtube.com/action/GetUploadToken");
            
            if (newEntry == null)
            {
                throw new ArgumentNullException("newEntry");
            }

            Stream returnStream = EntrySend(uri, newEntry, GDataRequestType.Insert);

            FormUploadToken token = new FormUploadToken(returnStream);

            returnStream.Close();

            return token;
        }
 public void YouTubeEntryConstructorTest()
 {
     YouTubeEntry target = new YouTubeEntry();
     Assert.IsNotNull(target,  "Object should not be null after construction");
 }