예제 #1
0
        public static bool UpdatePlaylist(YouTubeSession session, Playlist playlist)
        {
            var update = session.YouTubeService.Playlists.Update(playlist.Original, "snippet,status");
            var result = update.Execute();

            return(result != null);
        }
예제 #2
0
        public UploadQueueItem(YouTubeSession session, string filename)
        {
            youtubeSession = new WeakReference <YouTubeSession> (session);

            FileName    = new Uri(filename, UriKind.Absolute);
            mediaStream = new FileStream(HttpUtility.UrlDecode(FileName.AbsolutePath), FileMode.Open, FileAccess.Read, FileShare.Read);
            if (mediaStream.Length >= 68719476736)
            {
                mediaStream.Dispose();
                mediaStream = null;
                throw new ArgumentException("File size is to big.", "filename");
            }

            video = new Google.Apis.YouTube.v3.Data.Video()
            {
                Snippet = new VideoSnippet()
                {
                    Tags = new ObservableCollection <string> ()
                },
                Status = new VideoStatus()
            };

            Title         = Path.GetFileNameWithoutExtension(filename);
            Description   = "";
            PrivacyStatus = PrivacyStatus.Public;

            Progress        = 0;
            TotalUploaded   = 0;
            UploadingStatus = UploadingStatus.Queued;
        }
예제 #3
0
 public Video(YouTubeSession session, Google.Apis.YouTube.v3.Data.Video original = null)
 {
     youTubeSession = new WeakReference <YouTubeSession> (session);
     this.Original  = original ?? new Google.Apis.YouTube.v3.Data.Video()
     {
         Snippet = new Google.Apis.YouTube.v3.Data.VideoSnippet(),
         Status  = new Google.Apis.YouTube.v3.Data.VideoStatus()
     };
 }
예제 #4
0
 public Playlist(YouTubeSession session, Google.Apis.YouTube.v3.Data.Playlist original = null)
 {
     youTubeSession = new WeakReference <YouTubeSession> (session);
     this.Original  = original ?? new Google.Apis.YouTube.v3.Data.Playlist()
     {
         Snippet = new Google.Apis.YouTube.v3.Data.PlaylistSnippet(),
         Status  = new Google.Apis.YouTube.v3.Data.PlaylistStatus()
     };
     //Refresh ();
 }
예제 #5
0
        public static bool RemovePlaylist(YouTubeSession session, Playlist playlist)
        {
            if (playlist.Id == null)
            {
                return(false);
            }

            var delete = session.YouTubeService.Playlists.Delete(playlist.Id);
            var result = delete.Execute();

            return(result == null || result == "");
        }
예제 #6
0
        public static bool AddPlaylist(YouTubeSession session, string title, string description, PrivacyStatus privacyStatus)
        {
            if (privacyStatus == PrivacyStatus.Unlisted)
            {
                return(false);
            }

            Google.Apis.YouTube.v3.Data.Playlist pl = new Google.Apis.YouTube.v3.Data.Playlist();
            pl.Snippet = new Google.Apis.YouTube.v3.Data.PlaylistSnippet()
            {
                Title       = title,
                Description = description
            };
            pl.Status = new Google.Apis.YouTube.v3.Data.PlaylistStatus()
            {
                PrivacyStatus = privacyStatus.GetPrivacyStatus()
            };

            var insert = session.YouTubeService.Playlists.Insert(pl, "snippet,status");

            return(insert.Execute() != null);
        }
예제 #7
0
        public static async Task Refresh(YouTubeSession session)
        {
            (DetectedPlaylists as IList <Playlist>).Clear();

            string nextToken = null;

            do
            {
                var request = session.YouTubeService.Playlists.List("snippet,status");
                request.Mine       = true;
                request.MaxResults = 50;
                request.PageToken  = nextToken;
                request.Hl         = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
                var result = await request.ExecuteAsync();

                foreach (var item in result.Items)
                {
                    (DetectedPlaylists as IList <Playlist>).Add(new Playlist(session, item));
                }
                nextToken = result.NextPageToken;
            }while (nextToken != null);
        }
예제 #8
0
        public async Task Refresh(YouTubeSession session)
        {
            while (DetectedCategories.Count > 1)
            {
                (DetectedCategories as IList <VideoCategory>).RemoveAt(1);
            }

            var request = session.YouTubeService.VideoCategories.List("snippet");

            request.RegionCode = RegionInfo.CurrentRegion.TwoLetterISORegionName;
            request.Hl         = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;

            VideoCategoryListResponse result = null;
            int retry = 0;

            do
            {
                result = await request.ExecuteAsync();

                ++retry;
                if (retry == 30)
                {
                    return;
                }
            }while (result == null || result.Items == null);

            foreach (var i in result.Items)
            {
                if (i.Snippet.Assignable == false)
                {
                    continue;
                }
                VideoCategory item = new VideoCategory();
                item.Name = i.Snippet.Title;
                item.Id   = i.Id;
                (DetectedCategories as IList <VideoCategory>).Add(item);
            }
        }