コード例 #1
0
ファイル: PlaylistTasks.cs プロジェクト: Zeroth007/UltraSonic
        private void AddHighestRatedToPlaylists(Task<AlbumList> task)
        {
            switch (task.Status)
            {
                case TaskStatus.RanToCompletion:
                    Dispatcher.Invoke(() =>
                    {
                        AlbumList albumList = task.Result;
                        var tracks = albumList.Album.Where(a => !a.IsDir).ToList();
                        int duration = tracks.Sum(child => child.Duration);

                        PlaylistItem newHighestRatedPlaylist = new PlaylistItem
                        {
                            Duration = TimeSpan.FromSeconds(duration),
                            Name = "Highest Rated",
                            Tracks = tracks.Count,
                            Playlist = null
                        };

                        PlaylistItem currentHighestRatedPlaylist = _playlistItems.FirstOrDefault(p => p.Playlist == null && p.Name == "Highest Rated");

                        if (currentHighestRatedPlaylist == null)
                            _playlistItems.Add(newHighestRatedPlaylist);
                        else
                        {
                            _playlistItems.Remove(currentHighestRatedPlaylist);
                            _playlistItems.Add(newHighestRatedPlaylist);
                        }
                    });
                    break;
            }
        }
コード例 #2
0
        public void Update(PlaylistItem playlistItem)
        {
            try
            {
                NHibernateSessionManager.Instance.BeginTransaction();
                playlistItem.ValidateAndThrow();
                playlistItem.Video.ValidateAndThrow();

                PlaylistItem knownPlaylistItem = PlaylistItemDao.Get(playlistItem.Id);

                if (knownPlaylistItem == null)
                {
                    PlaylistItemDao.Update(playlistItem);
                }
                else
                {
                    PlaylistItemDao.Merge(playlistItem);
                }

                NHibernateSessionManager.Instance.CommitTransaction();
            }
            catch (Exception exception)
            {
                Logger.Error(exception);
                NHibernateSessionManager.Instance.RollbackTransaction();
                throw;
            }
        }
コード例 #3
0
    public PlaylistItem AddLast(PlaylistItem in_rItem)
    {
        IntPtr cPtr = AkSoundEnginePINVOKE.CSharp_AkPlaylistArray_AddLast__SWIG_1(swigCPtr, PlaylistItem.getCPtr(in_rItem));
        PlaylistItem ret = (cPtr == IntPtr.Zero) ? null : new PlaylistItem(cPtr, false);

        return ret;
    }
コード例 #4
0
        public PlaylistDto Create(PlaylistDto playlistDto)
        {
            PlaylistDto savedPlaylistDto;

            using (ITransaction transaction = Session.BeginTransaction())
            {
                User user = UserManager.Get(playlistDto.UserId);

                Playlist playlist = new Playlist(playlistDto.Id);
                playlistDto.SetPatchableProperties(playlist);

                user.AddPlaylist(playlist);

                List<PlaylistItem> playlistItems = new List<PlaylistItem>();
                foreach (PlaylistItemDto dto in playlistDto.Items)
                {
                    PlaylistItem playlistItem = new PlaylistItem(dto.Id, dto.Title, dto.Cid, dto.Song.Id, dto.Song.Type, dto.Song.Title, dto.Song.Duration, dto.Song.Author);
                    dto.SetPatchableProperties(playlistItem);
                    playlistItems.Add(playlistItem);
                }
                playlist.AddItems(playlistItems);

                PlaylistManager.Save(playlist);
                savedPlaylistDto = PlaylistDto.Create(playlist);

                transaction.Commit();
            }

            return savedPlaylistDto;
        }
コード例 #5
0
ファイル: Playlist.cs プロジェクト: hihihippp/Streamus
        public virtual void AddItem(PlaylistItem playlistItem)
        {
            //  Item must be removed from other Playlist before AddItem affects it.
            if (playlistItem.Playlist != null && playlistItem.Playlist.Id != Id)
            {
                string message = string.Format("Item {0} is already a child of Playlist {1}", playlistItem.Title, playlistItem.Playlist.Title);
                throw new Exception(message);
            }

            if (Items.Count == 0)
            {
                FirstItem = playlistItem;
                playlistItem.NextItem = playlistItem;
                playlistItem.PreviousItem = playlistItem;
            }
            else
            {
                PlaylistItem firstItem = FirstItem;
                PlaylistItem lastItem = firstItem.PreviousItem;

                //  Adjust our linked list and add the item.
                lastItem.NextItem = playlistItem;
                playlistItem.PreviousItem = lastItem;

                firstItem.PreviousItem = playlistItem;
                playlistItem.NextItem = firstItem;
            }

            playlistItem.Playlist = this;
            Items.Add(playlistItem);
        }
コード例 #6
0
ファイル: Playlist.cs プロジェクト: zeemEU/StreamusServer
        public virtual void AddItem(PlaylistItem playlistItem)
        {
            //  Item must be removed from other Playlist before AddItem affects it.
            if (playlistItem.Playlist != null && playlistItem.Playlist.Id != Id)
            {
                string message = string.Format("Item {0} is already a child of Playlist {1}", playlistItem.Title, playlistItem.Playlist.Title);
                throw new Exception(message);
            }

            //  Client might set the sequence number.
            if (playlistItem.Sequence < 0)
            {
                if (Items.Any())
                {
                    playlistItem.Sequence = Items.OrderBy(i => i.Sequence).Last().Sequence + 10000;
                }
                else
                {
                    playlistItem.Sequence = 10000;
                }
            }

            playlistItem.Playlist = this;
            Items.Add(playlistItem);
        }
コード例 #7
0
        public void AddSong(PlaylistItem playlistItem, bool preventDuplicate = false)
        {
            if (preventDuplicate && Playlist.Contains(playlistItem))
                return;

            this.Playlist.Add(playlistItem);
            OnSongAdded(playlistItem, new EventArgs());
        }
コード例 #8
0
        public void AddSong(String url, bool preventDuplicate = false)
        {
            PlaylistItem playlistItem = new PlaylistItem(url);
            if (preventDuplicate && Playlist.Contains(playlistItem) || !File.Exists(url) || !AudioControls.SupportedAudioFormats.Contains(Path.GetExtension(url).ToLower()))
                return;

            this.Playlist.Add(playlistItem);
            OnSongAdded(playlistItem, new EventArgs());
        }
コード例 #9
0
ファイル: Main.cs プロジェクト: Slashpwn/3D_Menu
    void next()
    {
        if(playlistPlay && !shuffle){

                currentSong = currentPlaylist.getNext(count);
                Debug.Log (currentSong.toString());
            count++;
        }
    }
コード例 #10
0
        public void ShouldMap()
        {
            var sessionFactory = new NHibernateConfiguration().Configure().BuildSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    var createdUser = new User {GooglePlusId = "some id?", Name = "user name"};
                    session.Save(createdUser);

                    var playlist2 = new Playlist("users second playlist")
                        {
                            User = createdUser,
                            Sequence = 200,
                        };

                    var video = new Video
                        {
                            Id = "some id",
                            Author = "video author",
                            Duration = 90,
                            HighDefinition = true,
                            Title = "my video",
                        };
                    session.Save(video);
                    var playlistItem = new PlaylistItem
                        {
                            Cid = "cid",
                            Playlist = playlist2,
                            Video = video,
                            Sequence = 300,
                            Title = "My playlist item",
                        };

                    playlist2.AddItem(playlistItem);

                    session.Save(playlist2);

                    session.Flush();
                    session.Clear();

                    var savedPlaylistItem = session.Get<PlaylistItem>(playlistItem.Id);

                    Assert.That(savedPlaylistItem.Title, Is.EqualTo("My playlist item"));
                    Assert.That(savedPlaylistItem.Id, Is.Not.EqualTo(Guid.Empty));
                    Assert.That(savedPlaylistItem.Sequence, Is.EqualTo(300));

                    Assert.That(savedPlaylistItem.Video, Is.EqualTo(playlistItem.Video));

                    transaction.Rollback();
                }
            }
        }
コード例 #11
0
 public void Save(PlaylistItem playlistItem)
 {
     try
     {
         DoSave(playlistItem);
     }
     catch (Exception exception)
     {
         Logger.Error(exception);
         throw;
     }
 }
コード例 #12
0
ファイル: YouTubeHelper.cs プロジェクト: mjdavy/TopTastic.net
 public static async Task<PlaylistItem> AddVideoToPlaylist(YouTubeService service,  string playlistId, string videoId)
 {
     // Add a video to the newly created playlist.
     var newPlaylistItem = new PlaylistItem();
     newPlaylistItem.Snippet = new PlaylistItemSnippet();
     newPlaylistItem.Snippet.PlaylistId = playlistId;
     newPlaylistItem.Snippet.ResourceId = new ResourceId();
     newPlaylistItem.Snippet.ResourceId.Kind = "youtube#video";
     newPlaylistItem.Snippet.ResourceId.VideoId = videoId;
     var playlistItemInsertReq = service.PlaylistItems.Insert(newPlaylistItem, "snippet");
     var item = await playlistItemInsertReq.ExecuteAsync();
     return item;
 }
コード例 #13
0
ファイル: Helpers.cs プロジェクト: hihihippp/Streamus
        /// <summary>
        ///     Creates a new Video and PlaylistItem, puts item in the database and then returns
        ///     the item. Just a nice utility method to keep things DRY.
        /// </summary>
        public static PlaylistItem CreateItemInPlaylist(Playlist playlist)
        {
            Video videoNotInDatabase = CreateUnsavedVideoWithId();

            //  Create a new PlaylistItem and write it to the database.
            string title = videoNotInDatabase.Title;
            var playlistItem = new PlaylistItem(title, videoNotInDatabase);

            playlist.AddItem(playlistItem);
            PlaylistItemManager.Save(playlistItem);

            return playlistItem;
        }
コード例 #14
0
ファイル: writer.cs プロジェクト: nahooda/cmdpls
 private void writeEntry(StreamWriter _swWriter, int counter, PlaylistItem objPlaylistItem, string fileFormat)
 {
     switch(fileFormat) {
         case "m3u":
                 _swWriter.WriteLine(objPlaylistItem.getFullPath());
             break;
         case "pls":
                 _swWriter.WriteLine("File" + (counter + 1) + "=" + objPlaylistItem.getFullPath());
             break;
         case "xspf":
                 _swWriter.WriteLine("\t\t<track>");
                 _swWriter.WriteLine("\t\t\t<location>file://" + objPlaylistItem.getFullPath() + "</location>");
                 _swWriter.WriteLine("\t\t</track>");
             break;
     }
 }
        public void Equals_ShouldReturnTrue()
        {
            var playlistItem1 = new PlaylistItem
            {
                Snippet = new PlaylistItemSnippet { Title = "Title 1", ResourceId = new ResourceId { VideoId = "dsfhahdfh" } }
            };
            var playlistItem2 = new PlaylistItem
            {
                Snippet = new PlaylistItemSnippet { Title = "Title 1", ResourceId = new ResourceId { VideoId = "dsfhahdfh" } }
            };

            var comparer = new PlaylistItemEqualityComparer();

            Assert.IsTrue(comparer.Equals(playlistItem1, playlistItem2));
            Assert.AreEqual(comparer.GetHashCode(playlistItem1), comparer.GetHashCode(playlistItem2));
        }
コード例 #16
0
        /// <summary>
        ///     Creates a new Video and PlaylistItem, puts item in the database and then returns
        ///     the item. Just a nice utility method to keep things DRY.
        /// </summary>
        public static PlaylistItem CreateItemInPlaylist(Playlist playlist)
        {
            Video videoNotInDatabase = CreateUnsavedVideoWithId();

            //  Create a new PlaylistItem and write it to the database.
            string title = videoNotInDatabase.Title;
            var playlistItem = new PlaylistItem(title, videoNotInDatabase);

            playlist.AddItem(playlistItem);

            NHibernateSessionManager.Instance.OpenSessionAndBeginTransaction();
            PlaylistItemManager.Save(playlistItem);
            NHibernateSessionManager.Instance.CommitTransactionAndCloseSession();

            return playlistItem;
        }
コード例 #17
0
ファイル: Playlist.cs プロジェクト: hihihippp/Streamus
        public virtual void Copy(Playlist playlist)
        {
            Title = playlist.Title;

            foreach (PlaylistItem playlistItem in playlist.Items)
            {
                PlaylistItem shareableItemCopy = new PlaylistItem(playlistItem);
                AddItem(shareableItemCopy);

                //  If the old playlist's firstItemId was the currently old item we're iterating over,
                //  set the current new item as the first item.
                if (playlistItem == playlist.FirstItem)
                {
                    FirstItem = shareableItemCopy;
                }
            }
        }
コード例 #18
0
        public void ShouldMap()
        {
            var sessionFactory = new NHibernateConfiguration().Configure().BuildSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    var createdUser = new User {GooglePlusId = "some id?", Name = "user name"};

                    session.Save(createdUser);

                    var playlist2 = new Playlist("users second playlist")
                        {
                            User = createdUser,
                            Sequence = 200,
                        };

                    var playlistItem = new PlaylistItem
                        {
                            Cid = "cid",
                            Playlist = playlist2,
                            Video = new Video(),
                            Sequence = 200,
                        };

                    playlist2.AddItem(playlistItem);

                    var playlistId = session.Save(playlist2);

                    session.Flush();
                    session.Clear();

                    var savedPlaylist = session.Get<Playlist>(playlistId);

                    Assert.That(savedPlaylist.Title, Is.EqualTo("users second playlist"));
                    Assert.That(savedPlaylist.Id, Is.Not.EqualTo(Guid.Empty));
                    Assert.That(savedPlaylist.Sequence, Is.EqualTo(200));

                    Assert.That(savedPlaylist.Items, Has.Exactly(1).EqualTo(playlistItem));

                    transaction.Rollback();
                }
            }
        }
コード例 #19
0
ファイル: frmMain.cs プロジェクト: AugustoRuiz/WYZTracker
        private void loadSong(string songPath)
        {
            try
            {
                PlaylistItem item = new PlaylistItem();
                item.FilePath = songPath;
                item.Song = SongManager.LoadSong(songPath);
                PlaylistItemBindingSource.Add(item);

                if (PlaylistItemBindingSource.Current == null)
                {
                    PlaylistItemBindingSource.MoveFirst();
                }
            }
            catch(Exception ex)
            {
                Logger.Log(ex.ToString());
            }
        }
コード例 #20
0
        public void ShouldMap()
        {
            using (var transaction = Session.BeginTransaction())
            {
                var createdUser = new User
                    {
                        GooglePlusId = "some id?"
                    };
                Session.Save(createdUser);

                var playlist2 = new Playlist("users second playlist")
                    {
                        User = createdUser,
                        Sequence = 200,
                    };

                var playlistItem = new PlaylistItem
                    {
                        Playlist = playlist2,
                        SongId = "some id",
                        Author = "author",
                        Duration = 90,
                        Sequence = 300,
                        Title = "My playlist item",
                    };

                playlist2.AddItem(playlistItem);

                Session.Save(playlist2);

                Session.Flush();
                Session.Clear();

                var savedPlaylistItem = Session.Get<PlaylistItem>(playlistItem.Id);

                Assert.That(savedPlaylistItem.Title, Is.EqualTo("My playlist item"));
                Assert.That(savedPlaylistItem.Id, Is.Not.EqualTo(Guid.Empty));
                Assert.That(savedPlaylistItem.Sequence, Is.EqualTo(300));

                transaction.Rollback();
            }
        }
コード例 #21
0
        public YoutubeVideoItem(PlaylistItem item, int relevance) :
            base(item.Snippet.Title, item, relevance)
        {
            ChannelTitle = item.Snippet.ChannelTitle;
            ChannelId = item.Snippet.ChannelId;

            ResourceId = item.Snippet.ResourceId;
            Thumbnail = item.Snippet.Thumbnails;

            PublishedAt = item.Snippet.PublishedAt;
            Description = item.Snippet.Description;

            VideoId = item.Snippet.ResourceId.VideoId;

            IsEmbeddedOnly = false;

            Info = item;

            StreamedItem = new List<YoutubeVideoStreamedItem>();
        }
コード例 #22
0
        public void ShouldMap()
        {
            using (var transaction = Session.BeginTransaction())
            {
                var createdUser = new User
                    {
                        GooglePlusId = "some id?"
                    };

                Session.Save(createdUser);

                var playlist2 = new Playlist("users second playlist")
                    {
                        User = createdUser,
                        Sequence = 200,
                    };

                var playlistItem = new PlaylistItem
                    {
                        Playlist = playlist2,
                        Sequence = 200,
                    };

                playlist2.AddItem(playlistItem);

                var playlistId = Session.Save(playlist2);

                Session.Flush();
                Session.Clear();

                var savedPlaylist = Session.Get<Playlist>(playlistId);

                Assert.That(savedPlaylist.Title, Is.EqualTo("users second playlist"));
                Assert.That(savedPlaylist.Id, Is.Not.EqualTo(Guid.Empty));
                Assert.That(savedPlaylist.Sequence, Is.EqualTo(200));

                Assert.That(savedPlaylist.Items, Has.Exactly(1).EqualTo(playlistItem));

                transaction.Rollback();
            }
        }
コード例 #23
0
ファイル: Program.cs プロジェクト: paulamoisa/LabDATC
            private async Task Run()
            {
                UserCredential credential;
                using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
                {
                    credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
                        GoogleClientSecrets.Load(stream).Secrets,
                        // This OAuth 2.0 access scope allows for full read/write access to the
                        // authenticated user's account.
                        new[] { YouTubeService.Scope.Youtube },
                        "user",
                        CancellationToken.None,
                        new FileDataStore(this.GetType().ToString())
                    );
                }
                var youtubeService = new YouTubeService(new BaseClientService.Initializer()
                {
                    HttpClientInitializer = credential,
                    ApplicationName = this.GetType().ToString()
                });

                // Create a new, private playlist in the authorized user's channel.
                var newPlaylist = new Playlist();
                newPlaylist.Snippet = new PlaylistSnippet();
                newPlaylist.Snippet.Title = "Gorgon City";
                newPlaylist.Snippet.Description = "A playlist created with the YouTube API v3";
                newPlaylist.Status = new PlaylistStatus();
                newPlaylist.Status.PrivacyStatus = "public";
                newPlaylist = await youtubeService.Playlists.Insert(newPlaylist, "snippet,status").ExecuteAsync();

                // Add a video to the newly created playlist.
                var newPlaylistItem = new PlaylistItem();
                newPlaylistItem.Snippet = new PlaylistItemSnippet();
                newPlaylistItem.Snippet.PlaylistId = newPlaylist.Id;
                newPlaylistItem.Snippet.ResourceId = new ResourceId();
                newPlaylistItem.Snippet.ResourceId.Kind = "youtube#video";
                newPlaylistItem.Snippet.ResourceId.VideoId = "QxG53rIwaNw";
                newPlaylistItem = await youtubeService.PlaylistItems.Insert(newPlaylistItem, "snippet").ExecuteAsync();

                Console.WriteLine("Playlist item id {0} was added to playlist id {1}.", newPlaylistItem.Id, newPlaylist.Id);
            }
コード例 #24
0
        public PlaylistItemDto Create(PlaylistItemDto playlistItemDto)
        {
            PlaylistItemDto savedPlaylistItemDto;

            using(ITransaction transaction = Session.BeginTransaction())
            {
                Playlist playlist = PlaylistManager.Get(playlistItemDto.PlaylistId);

                SongDto songDto = playlistItemDto.Song;

                PlaylistItem playlistItem = new PlaylistItem(playlistItemDto.Id, playlistItemDto.Sequence, playlistItemDto.Title,  playlistItemDto.Cid, songDto.Id, songDto.Type, songDto.Title, songDto.Duration, songDto.Author);
                playlist.AddItem(playlistItem);

                PlaylistItemManager.Save(playlistItem);

                savedPlaylistItemDto = PlaylistItemDto.Create(playlistItem);

                transaction.Commit();
            }

            return savedPlaylistItemDto;
        }
コード例 #25
0
        public void CreateItem_NotAddedToPlaylistBeforeSave_ItemNotAdded()
        {
            Video videoNotInDatabase = Helpers.CreateUnsavedVideoWithId();

            //  Create a new PlaylistItem and write it to the database.
            string title = videoNotInDatabase.Title;
            var playlistItem = new PlaylistItem(title, videoNotInDatabase);

            bool validationExceptionEncountered = false;

            try
            {
                //  Try to save the item without adding to Playlist. This should fail.
                PlaylistItemManager.Save(playlistItem);
            }
            catch (ValidationException)
            {
                validationExceptionEncountered = true;
            }

            Assert.IsTrue(validationExceptionEncountered);
        }
コード例 #26
0
    static void Main(string[] args)
    {
      CommandLine.EnableExceptionHandling();
      CommandLine.DisplayGoogleSampleHeader("YouTube Data API: Playlist Updates");

      var credentials = PromptingClientCredentials.EnsureFullClientCredentials();
      var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description)
      {
        ClientIdentifier = credentials.ClientId,
        ClientSecret = credentials.ClientSecret
      };
      var auth = new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthorization);

      var youtube = new YoutubeService(new BaseClientService.Initializer()
      {
        Authenticator = auth
      });

      var newPlaylist = new Playlist();
      newPlaylist.Snippet = new PlaylistSnippet();
      newPlaylist.Snippet.Title = "Test Playlist";
      newPlaylist.Snippet.Description = "A playlist created with the YouTube API v3";
      newPlaylist.Status = new PlaylistStatus();
      newPlaylist.Status.PrivacyStatus = "public";
      newPlaylist = youtube.Playlists.Insert(newPlaylist, "snippet,status").Fetch();

      var newPlaylistItem = new PlaylistItem();
      newPlaylistItem.Snippet = new PlaylistItemSnippet();
      newPlaylistItem.Snippet.PlaylistId = newPlaylist.Id;
      newPlaylistItem.Snippet.ResourceId = new ResourceId();
      newPlaylistItem.Snippet.ResourceId.Kind = "youtube#video";
      newPlaylistItem.Snippet.ResourceId.VideoId = "GNRMeaz6QRI";
      newPlaylistItem = youtube.PlaylistItems.Insert(newPlaylistItem, "snippet").Fetch();

      CommandLine.WriteLine(String.Format("Playlist item id {0} was added to playlist id {1}.", newPlaylistItem.Id, newPlaylist.Id));

      CommandLine.PressAnyKeyToExit();
    }
コード例 #27
0
 public void Play(PlaylistItem item, object options = null)
 {
     throw new NotImplementedException();
 }
コード例 #28
0
ファイル: Program.cs プロジェクト: sjorv/SidWizPlus
        private static async Task <string> UploadToYouTube(Settings settings)
        {
            ClientSecrets secrets;

            if (settings.YouTubeUploadClientSecret != null)
            {
                using (var stream = new FileStream(settings.YouTubeUploadClientSecret, FileMode.Open, FileAccess.Read))
                {
                    secrets = GoogleClientSecrets.Load(stream).Secrets;
                }
            }
            else
            {
                // We use our embedded client secret
                using (var stream = Properties.Resources.ResourceManager.GetStream(nameof(Properties.Resources.ClientSecret)))
                {
                    secrets = GoogleClientSecrets.Load(stream).Secrets;
                }
            }

            var credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
                secrets,
                // This OAuth 2.0 access scope allows an application to upload files to the
                // authenticated user's YouTube channel, but doesn't allow other types of access.
                new[] { YouTubeService.Scope.YoutubeUpload, YouTubeService.Scope.YoutubeForceSsl },
                "SidWizPlus",
                CancellationToken.None
                );

            var youtubeService = new YouTubeService(new BaseClientService.Initializer
            {
                HttpClientInitializer = credential,
                ApplicationName       = Assembly.GetExecutingAssembly().GetName().Name,
                GZipEnabled           = true
            });

            var video = new Video
            {
                Snippet = new VideoSnippet
                {
                    Title      = settings.YouTubeTitle,
                    CategoryId = "10" // Music
                },
                Status = new VideoStatus {
                    PrivacyStatus = "public"
                }
                // or "private" or "public"
            };

            var tags = new List <string>();

            if (settings.YouTubeTags != null)
            {
                tags.AddRange(settings.YouTubeTags.Split(','));
            }

            Gd3Tag gd3 = null;

            if (settings.VgmFile != null)
            {
                gd3 = Gd3Tag.LoadFromVgm(settings.VgmFile);
            }

            if (gd3 != null)
            {
                video.Snippet.Description = $"Oscilloscope View of {gd3.Title}";
                if (gd3.Game.English.Length > 0)
                {
                    video.Snippet.Description += $" from the game {gd3.Game.English}";
                }
                if (gd3.System.English.Length > 0)
                {
                    video.Snippet.Description += $" for the {gd3.System.English}";
                }
                if (gd3.Composer.English.Length > 0)
                {
                    video.Snippet.Description += $", composed by {gd3.Composer}";
                }
                video.Snippet.Description += ".";
                if (gd3.Ripper.Length > 0)
                {
                    video.Snippet.Description += $"\nRipped by {gd3.Ripper}";
                }
                if (gd3.Notes.Length > 0)
                {
                    video.Snippet.Description += "\n\nNotes:\n" + gd3.Notes;
                }
            }

            if (settings.YouTubeDescriptionsExtra != null)
            {
                video.Snippet.Description += "\n" + settings.YouTubeDescriptionsExtra;
            }

            video.Snippet.Description += "\n\nVideo created using SidWizPlus - https://github.com/maxim-zhao/SidWizPlus";

            if (settings.YouTubeTagsFromGd3 && gd3 != null)
            {
                tags.Add(gd3.Game.English);
                tags.Add(gd3.System.English);
                tags.AddRange(gd3.Composer.English.Split(';'));
            }

            video.Snippet.Tags = tags.Where(t => !string.IsNullOrEmpty(t)).Select(t => t.Trim()).ToList();

            if (settings.YouTubeCategory != null)
            {
                var request = youtubeService.VideoCategories.List("snippet");
                request.RegionCode = "US";
                var response = request.Execute();
                video.Snippet.CategoryId = response.Items
                                           .Where(c => c.Snippet.Title.ToLowerInvariant().Contains(settings.YouTubeCategory.ToLowerInvariant()))
                                           .Select(c => c.Id)
                                           .FirstOrDefault();
                if (video.Snippet.CategoryId == null)
                {
                    Console.Error.WriteLine($"Warning: couldn't find category matching \"{settings.YouTubeCategory}\", defaulting to \"Music\"");
                }
            }

            if (gd3 != null)
            {
                video.Snippet.Title = FormatFromGd3(video.Snippet.Title, gd3);
            }

            if (video.Snippet.Title.Length > 100)
            {
                video.Snippet.Title = video.Snippet.Title.Substring(0, 97) + "...";
            }

            // We now escape some strings as the API doesn't do it internally...
            video.Snippet.Title       = RemoveAngledBrackets(video.Snippet.Title);
            video.Snippet.Description = RemoveAngledBrackets(video.Snippet.Description);
            video.Snippet.Tags        = video.Snippet.Tags.Select(RemoveAngledBrackets).ToList();

            using (var fileStream = new FileStream(settings.OutputFile, FileMode.Open))
            {
                var videosInsertRequest = youtubeService.Videos.Insert(video, "snippet,status", fileStream, "video/*");
                videosInsertRequest.ChunkSize = ResumableUpload.MinimumChunkSize;
                long totalSize   = fileStream.Length;
                bool shouldRetry = true;
                var  sw          = Stopwatch.StartNew();
                videosInsertRequest.ProgressChanged += progress =>
                {
                    switch (progress.Status)
                    {
                    case UploadStatus.Uploading:
                    {
                        var elapsedSeconds   = sw.Elapsed.TotalSeconds;
                        var fractionComplete = (double)progress.BytesSent / totalSize;
                        var eta         = TimeSpan.FromSeconds(elapsedSeconds / fractionComplete - elapsedSeconds);
                        var sent        = (double)progress.BytesSent / 1024 / 1024;
                        var kbPerSecond = progress.BytesSent / sw.Elapsed.TotalSeconds / 1024;
                        Console.Write($"\r{sent:f}MB sent ({fractionComplete:P}, average {kbPerSecond:f}KB/s, ETA {eta:g})");
                        break;
                    }

                    case UploadStatus.Failed:
                        Console.Error.WriteLine($"Upload failed: {progress.Exception}");
                        // Google API says we can retry if we get a non-API error, or one of these four 5xx error codes
                        shouldRetry = !(progress.Exception is GoogleApiException errorCode) ||
                                      new[] {
                            HttpStatusCode.InternalServerError, HttpStatusCode.BadGateway,
                            HttpStatusCode.ServiceUnavailable, HttpStatusCode.GatewayTimeout
                        }.Contains(errorCode.HttpStatusCode);
                        if (shouldRetry)
                        {
                            Console.WriteLine("Retrying...");
                        }
                        break;

                    case UploadStatus.Completed:
                        Console.WriteLine($"Progress: {progress.Status}");
                        shouldRetry = false;
                        break;

                    default:
                        Console.WriteLine($"Progress: {progress.Status}");
                        break;
                    }
                };
                videosInsertRequest.ResponseReceived += video1 =>
                {
                    video.Id = video1.Id;
                    Console.WriteLine($"\nUpload completed: video ID is {video1.Id}");
                };

                try
                {
                    videosInsertRequest.Upload();
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine($"Upload failed: {ex}");
                }

                while (shouldRetry)
                {
                    try
                    {
                        videosInsertRequest.Resume();
                    }
                    catch (Exception ex)
                    {
                        Console.Error.WriteLine($"Upload failed: {ex}");
                    }
                }
            }

            if (settings.YouTubePlaylist != null && !string.IsNullOrEmpty(video.Id))
            {
                if (gd3 != null)
                {
                    settings.YouTubePlaylist = RemoveAngledBrackets(FormatFromGd3(settings.YouTubePlaylist, gd3));
                }

                // We need to decide if it's an existing playlist

                // We iterate over all channels...
                var playlistsRequest = youtubeService.Playlists.List("snippet");
                playlistsRequest.Mine = true;
                var playlistsResponse = playlistsRequest.Execute();
                var playlist          = playlistsResponse.Items.FirstOrDefault(p => p.Snippet.Title == settings.YouTubePlaylist);
                if (playlist == null)
                {
                    // Create it
                    playlist = new Playlist
                    {
                        Snippet = new PlaylistSnippet
                        {
                            Title = settings.YouTubePlaylist
                        },
                        Status = new PlaylistStatus
                        {
                            PrivacyStatus = "public"
                        }
                    };
                    if (settings.YouTubePlaylistDescriptionFile != null)
                    {
                        playlist.Snippet.Description = RemoveAngledBrackets(File.ReadAllText(settings.YouTubePlaylistDescriptionFile));
                    }

                    if (settings.YouTubeDescriptionsExtra != null)
                    {
                        playlist.Snippet.Description += "\n\n" + settings.YouTubeDescriptionsExtra;
                    }

                    playlist = youtubeService.Playlists.Insert(playlist, "snippet, status").Execute();
                    Console.WriteLine($"Created playlist \"{settings.YouTubePlaylist}\" with ID {playlist.Id}");
                }

                // Add to it
                var newPlaylistItem = new PlaylistItem
                {
                    Snippet = new PlaylistItemSnippet
                    {
                        PlaylistId = playlist.Id,
                        ResourceId = new ResourceId {
                            Kind = "youtube#video", VideoId = video.Id
                        }
                    }
                };
                newPlaylistItem = await youtubeService.PlaylistItems.Insert(newPlaylistItem, "snippet").ExecuteAsync();

                Console.WriteLine($"Added video {video.Id} ({video.Snippet.Title}) to playlist {playlist.Id} ({playlist.Snippet.Title}) as item {newPlaylistItem.Id}");
            }

            return(video.Id);
        }
コード例 #29
0
 public IPlayer GetPlayerFor(PlaylistItem item)
 {
     throw new NotImplementedException();
 }
コード例 #30
0
ファイル: TimeshiftResultsScreen.cs プロジェクト: wlawt/osu
 public TimeshiftResultsScreen(ScoreInfo score, int roomId, PlaylistItem playlistItem, bool allowRetry = true)
     : base(score, allowRetry)
 {
     this.roomId       = roomId;
     this.playlistItem = playlistItem;
 }
コード例 #31
0
 public PlaylistDownloadButton(PlaylistItem playlistItem)
     : base(playlistItem.Beatmap.Value.BeatmapSet)
 {
     this.playlistItem = playlistItem;
     Alpha             = 0;
 }
コード例 #32
0
ファイル: MultiplayerQueueList.cs プロジェクト: roridev/osu
 protected override DrawableRoomPlaylistItem CreateDrawablePlaylistItem(PlaylistItem item) => new QueuePlaylistItem(item);
コード例 #33
0
 internal static IntPtr getCPtr(PlaylistItem obj)
 {
     return((obj == null) ? IntPtr.Zero : obj.swigCPtr);
 }
コード例 #34
0
    public Iterator FindEx(PlaylistItem in_Item)
    {
        Iterator ret = new Iterator(AkSoundEnginePINVOKE.CSharp_AkPlaylistArray_FindEx(swigCPtr, PlaylistItem.getCPtr(in_Item)), true);

        return(ret);
    }
コード例 #35
0
    public AKRESULT RemoveSwap(PlaylistItem in_rItem)
    {
        AKRESULT ret = (AKRESULT)AkSoundEnginePINVOKE.CSharp_AkPlaylistArray_RemoveSwap(swigCPtr, PlaylistItem.getCPtr(in_rItem));

        return(ret);
    }
コード例 #36
0
    public PlaylistItem AddLast(PlaylistItem in_rItem)
    {
        IntPtr       cPtr = AkSoundEnginePINVOKE.CSharp_AkPlaylistArray_AddLast__SWIG_1(swigCPtr, PlaylistItem.getCPtr(in_rItem));
        PlaylistItem ret  = (cPtr == IntPtr.Zero) ? null : new PlaylistItem(cPtr, false);

        return(ret);
    }
コード例 #37
0
 private void updateSelectedItem(PlaylistItem item)
 {
     hasBeatmap = findBeatmap(expr => beatmaps.QueryBeatmap(expr));
 }
コード例 #38
0
    public PlaylistItem GetItem()
    {
        PlaylistItem ret = new PlaylistItem(AkSoundEnginePINVOKE.CSharp_Iterator_GetItem(swigCPtr), false);

        return(ret);
    }
コード例 #39
0
 public PlaylistItem(PlaylistItem in_rCopy) : this(AkSoundEnginePINVOKE.CSharp_new_PlaylistItem__SWIG_1(PlaylistItem.getCPtr(in_rCopy)), true)
 {
 }
コード例 #40
0
ファイル: MultiplayerQueueList.cs プロジェクト: roridev/osu
 public QueuePlaylistItem(PlaylistItem item)
     : base(item)
 {
 }
コード例 #41
0
    public PlaylistItem Assign(PlaylistItem in_rCopy)
    {
        PlaylistItem ret = new PlaylistItem(AkSoundEnginePINVOKE.CSharp_PlaylistItem_Assign(swigCPtr, PlaylistItem.getCPtr(in_rCopy)), false);

        return(ret);
    }
コード例 #42
0
ファイル: YouTubeApi.cs プロジェクト: comburo/yotwalf
        public async Task AddVideoToPlayList(string videoId, string playListId)
        {
            var playListItem = new PlaylistItem
            {
                Snippet = new PlaylistItemSnippet
                {
                    PlaylistId= playListId,
                    ResourceId = new ResourceId
                    {
                        VideoId = videoId,
                        Kind = "youtube#video"
                    }
                }
            };

            var itemRequest = Service.PlaylistItems.Insert(playListItem, "snippet");
            var result = await itemRequest.ExecuteAsync();
        }
コード例 #43
0
    public bool IsEqualTo(PlaylistItem in_rCopy)
    {
        bool ret = AkSoundEnginePINVOKE.CSharp_PlaylistItem_IsEqualTo(swigCPtr, PlaylistItem.getCPtr(in_rCopy));

        return(ret);
    }
コード例 #44
0
 public TestResultsScreen(ScoreInfo score, int roomId, PlaylistItem playlistItem, bool allowRetry = true)
     : base(score, roomId, playlistItem, allowRetry)
 {
 }
コード例 #45
0
 internal SkipToPlaylistItemEventArgs(PlaylistItem playlistItem)
 {
     Cancel = false;
     PlaylistItem = playlistItem;
 }
コード例 #46
0
    public PlaylistItem Exists(PlaylistItem in_Item)
    {
        IntPtr       cPtr = AkSoundEnginePINVOKE.CSharp_AkPlaylistArray_Exists(swigCPtr, PlaylistItem.getCPtr(in_Item));
        PlaylistItem ret  = (cPtr == IntPtr.Zero) ? null : new PlaylistItem(cPtr, false);

        return(ret);
    }
コード例 #47
0
ファイル: MatchSubScreen.cs プロジェクト: nbayt/osu
 private void addPlaylistItem(PlaylistItem item)
 {
     bindings.Playlist.Clear();
     bindings.Playlist.Add(item);
 }
コード例 #48
0
    public PlaylistItem Last()
    {
        PlaylistItem ret = new PlaylistItem(AkSoundEnginePINVOKE.CSharp_AkPlaylistArray_Last(swigCPtr), false);

        return(ret);
    }
コード例 #49
0
        public void Ctor_Always_SetsCoverArtUrlToPlaceholder()
        {
            var playlistItem = new PlaylistItem();

            playlistItem.CoverArtUrl.Should().Be(SubsonicService.CoverArtPlaceholder);
        }
コード例 #50
0
    public PlaylistItem ItemAtIndex(uint uiIndex)
    {
        PlaylistItem ret = new PlaylistItem(AkSoundEnginePINVOKE.CSharp_AkPlaylistArray_ItemAtIndex(swigCPtr, uiIndex), false);

        return(ret);
    }
コード例 #51
0
        public void Ctor_Always_SetsPlayingStateToNotPlaying()
        {
            var playlistItem = new PlaylistItem();

            playlistItem.PlayingState.Should().Be(PlaylistItemState.NotPlaying);
        }
コード例 #52
0
        public void CreateItem_VideoAlreadyExists_ItemCreatedVideoNotUpdated()
        {
            var videoNotInDatabase = Helpers.CreateUnsavedVideoWithId();
            VideoManager.Save(videoNotInDatabase);

            //  Change the title for videoInDatabase to check that cascade-update does not affect title. Videos are immutable.
            const string videoTitle = "A video title";
            var videoInDatabase = Helpers.CreateUnsavedVideoWithId(titleOverride: videoTitle);

            //  Create a new PlaylistItem and write it to the database.
            string title = videoInDatabase.Title;
            var playlistItem = new PlaylistItem(title, videoInDatabase);

            Playlist.AddItem(playlistItem);
            PlaylistItemManager.Save(playlistItem);

            //  Remove entity from NHibernate cache to force DB query to ensure actually created.
            NHibernateSessionManager.Instance.Clear();

            //  Ensure that the Video was NOT updated by comparing the new title to the old one.
            Video videoFromDatabase = VideoDao.Get(videoNotInDatabase.Id);
            Assert.AreNotEqual(videoFromDatabase.Title, videoTitle);

            //  Ensure that the PlaylistItem was created.
            PlaylistItem itemFromDatabase = PlaylistItemDao.Get(playlistItem.Id);
            Assert.NotNull(itemFromDatabase);

            //  Pointers should be self-referential with only one item in the Playlist.
            Assert.AreEqual(itemFromDatabase.NextItem, itemFromDatabase);
            Assert.AreEqual(itemFromDatabase.PreviousItem, itemFromDatabase);
        }
コード例 #53
0
 public void Setup()
 {
     _subject = new PlaylistItem();
 }
コード例 #54
0
ファイル: Helpers.cs プロジェクト: vefve/StreamusServer
        /// <summary>
        ///     Creates a new Video with a random Id, or a given Id if specified, saves it to the database and returns it.
        /// </summary>
        public PlaylistItem CreateUnsavedPlaylistItem(string videoIdOverride = "", string titleOverride = "")
        {
            //  Create a random video ID to ensure the Video doesn't exist in the database currently.
            string randomVideoId = videoIdOverride == string.Empty ? Guid.NewGuid().ToString().Substring(0, 11) : videoIdOverride;
            string title = titleOverride == string.Empty ? string.Format("Video {0}", randomVideoId) : titleOverride;
            var playlistItem = new PlaylistItem(title, randomVideoId, "111", SongType.YouTube, title, 999, "Author");

            return playlistItem;
        }
コード例 #55
0
        public VideoInfoControlViewModel(Database.NicoVideo nicoVideo, bool isNgEnabled = true, PlaylistItem playlistItem = null, bool requireLatest = true, IScheduler eventScheduler = null)
        {
            RawVideoId           = nicoVideo.RawVideoId;
            PlaylistItem         = playlistItem;
            _CompositeDisposable = new CompositeDisposable();

            _IsNGEnabled    = isNgEnabled;
            _EventShceduler = eventScheduler;

            _IsRequireLatest = requireLatest;

            OnDeferredUpdate().ConfigureAwait(false);
        }