예제 #1
0
        public async Task ProcessFile(string file, eMediaType mediaType)
        {
            if (!File.Exists(file))
            {
                throw new IOException($"File Path Missing: {file}");
            }

            string fileName       = Path.GetFileName(file);
            string processingPath = Path.Join(GetFolderPath(mediaType, _options.ProcessingStore), fileName);

            await FileHelper.DeleteExistingFileWithRetryAsync(processingPath, _log);

            await FileHelper.CopyFileWithRetryAsync(file, processingPath, _log);

            // add delay to ensure any file lock is removed.
            await Task.Delay(1000);

            string processedPath = GetFolderPath(mediaType, _options.ProcessedStore);
            await _converter.Convert(processingPath, processedPath, burnSubtitles : mediaType == eMediaType.Anime);

            NotifyProcessedFile(mediaType, fileName);

            // Clean up the ProcessingFolder + the original origin of the file.
            await Task.WhenAll(
                FileHelper.DeleteExistingFileWithRetryAsync(processingPath, _log),
                FileHelper.DeleteExistingFileWithRetryAsync(file, _log));
        }
예제 #2
0
        public CallLogPlayer(string pAudioFileUrl, bool pFromStream = false)
        {
            InitializeComponent();
            int _volume = 50;
            audio_settings _item = null;
            using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(UserSession.EntityConnection)) {
                _item = _efDbContext.audio_settings.FirstOrDefault(i => i.user_id == UserSession.CurrentUser.UserId);
                if (_item != null)
                    _efDbContext.Detach(_item);
            }

            if (_item != null && _item.speaker_volume > 0)
                _volume = Convert.ToInt32(_item.speaker_volume * 10);

            if (pFromStream)
                m_MediaType = eMediaType.Stream;
            else if (Path.GetExtension(pAudioFileUrl) == ".wav")
                m_MediaType = eMediaType.WavFile;
            else if (Path.GetExtension(pAudioFileUrl) == ".mp3")
                m_MediaType = eMediaType.Mp3File;

            m_MediaFile = pAudioFileUrl;
            trackBarControl.Properties.Minimum = 0;
            if (!pFromStream) {
                FileInfo info = new FileInfo(pAudioFileUrl);
                if (info.Length == 0) {
                    NotificationDialog.Information("Player", "Audio file don't have any content.");
                    m_CanBePlayed = false;
                    return;
                }
            }

            if (pFromStream) {
                //checking for  m_MediaFile

            }

            if (!this.IsMediaValidated()) {
                m_CanBePlayed = false;
                return;
            }

            if (m_MediaType == eMediaType.Mp3File)
                this.InitializeMp3Audio();
            else if (m_MediaType == eMediaType.WavFile)
                this.InitializeWavAudio();
            else if (m_MediaType == eMediaType.Stream)
                if (!this.InitializeStreamAudio())
                    return;

            m_CanBePlayed = true;
            if (!this.IsDisposed)
                this.btnPlay_Click(null, null);
        }
예제 #3
0
 public ucPlaylistModel(DatabasePlaylist ddb)
 {
     db = ddb;
     MusicsFocusCommand  = new DelegateCommand(doListFocus, CanListFocus);
     RequestFocusCommand = new DelegateCommand(doRequestFocus, CanRequestFocus);
     OpenFile            = new DelegateCommand(doOpenFile, CanOpenFile);
     Listdata            = eMediaType.MUSIC;
     //            mediaList = new ObservableCollection<Media>(db.ListCurrent);
     CreatePlaylist = new DelegateCommand(doCreateList, CanCreateList);
     affAbout       = new DelegateCommand(doAffAbout, CanAffAbout);
     islinqRequest  = false;
     Actualizedico();
 }
예제 #4
0
 public async Task ProcessFiles(IEnumerable <string> files, eMediaType mediaType)
 {
     // Process each file individually.
     // A file failure should not impact the others.
     foreach (var file in files)
     {
         try {
             await ProcessFile(file, mediaType);
         }
         catch (Exception ex) {
             _log.LogError(ex, $"Failed to process: {file}");
         }
     }
 }
예제 #5
0
        private string GetFolderPath(eMediaType mediaType, string area)
        {
            switch (mediaType)
            {
            case eMediaType.Anime:
                return(GetAnimeFolderPath(area));

            case eMediaType.Show:
                return(GetShowFolderPath(area));

            case eMediaType.Movie:
            default:
                throw new NotImplementedException($"{mediaType} not implemented.");
            }
        }
예제 #6
0
 public Media(string newPath, eMediaType newType)
 {
     path = newPath;
     type = newType;
     name = System.IO.Path.GetFileNameWithoutExtension(path);
     artist = null;
     album = null;
     genre = null;
     length = TimeSpan.FromSeconds(0);
     if (System.IO.Path.GetExtension(path) != ".mkv")
         getInfoMedia();
     title = (title != null ? title : name);
     artist = (artist != null ? artist : "Unknown artist");
     album = (album != null ? album : "Unknown album");
     genre = (genre != null ? genre : "Unknown genre");
 }
예제 #7
0
        public void loadPath(String path, int _nb, ObservableCollection <Media> _listinCurr)
        {
            if (File.Exists(path))
            {
                pause      = true;
                TextPlay   = "|>";
                listinCurr = _listinCurr;
                try
                {
                    TagLib.File       tagfile = TagLib.File.Create(path);
                    String            artist  = tagfile.Tag.FirstArtist;
                    TagLib.Properties p       = tagfile.Properties;
                    TagLib.MediaTypes mt      = p.MediaTypes;
                    if (mt == TagLib.MediaTypes.Audio)
                    {
                        mediatype = eMediaType.SOUND;
                        db.addSound(path);
                        myMedElem.Source = new Uri(path);
                        nb = _nb;
                    }
                    else if (mt == TagLib.MediaTypes.Photo)
                    {
                        mediatype = eMediaType.PICTURE;
                        db.addPicture(path);

                        myMedElem.Source = new Uri(path);
                        pause            = false;
                        TextPlay         = "||";
                        myMedElem.Play();
                        nb = _nb;
                    }
                    else if ((p.MediaTypes & TagLib.MediaTypes.Video) != TagLib.MediaTypes.None)
                    {
                        mediatype = eMediaType.VIDEO;
                        db.addVideo(path);
                        myMedElem.Source = new Uri(path);
                        nb = _nb;
                    }
                }
                catch (TagLib.UnsupportedFormatException e)
                {
                }
            }
        }
예제 #8
0
        private async Task ProcessFile(string file)
        {
            try {
                _log.LogInformation($"Processing File: {file}");
                eMediaType media = GetMediaTypeFromPath(file);

                if (media == eMediaType.Anime || media == eMediaType.Show)
                {
                    await _episodeProcessor.ProcessAsync(file, media);
                }
                else
                {
                    throw new NotImplementedException($"Media type not supported yet: {media} (Path: {file})");
                }
            }
            catch (EpisodeNotFoundException) {
                // Already logged further down. We can go on freely.
            }
            catch (Exception ex) {
                _log.LogError(ex, "Error with request to MediaInfo.");
            }
        }
예제 #9
0
        /// <summary>
        /// Processes the episode file passed into storage.
        /// </summary>
        public async Task ProcessAsync(string path, eMediaType mediaType)
        {
            if (mediaType == eMediaType.Movie)
            {
                throw new ArgumentException("Media Type is not an episode");
            }

            string episodeFileName      = Path.GetFileName(path);
            EpisodeSearchResult episode = await _mediaInfoRepository.EpisodeSearch(episodeFileName);

            if (episode?.Id > 0)
            {
                await ProcessFoundEpisodeAsync(path, episode, mediaType);

                _broker.Publish(mediaType.ToString(), episode.Id, "StorageProcessed");
            }
            else
            {
                _logger.LogWarning($"Did not process '{episodeFileName}' as it was not found by the media information service. Show Id: {episode?.ShowId.ToString() ?? "0 (SHOW NOT FOUND)"} / Full path: {path}");
                throw new EpisodeNotFoundException();
            }
        }
예제 #10
0
        public CallLogPlayer(string pAudioFileUrl)
        {
            InitializeComponent();
            int _volume = 50;
            BrightPlatformEntities _efDbContext = new BrightPlatformEntities(UserSession.EntityConnection);
            audio_settings _item = _efDbContext.audio_settings.FirstOrDefault(i => i.user_id == UserSession.CurrentUser.UserId);
            if (_item != null)
                if (_item.speaker_volume != null)
                    if (_item.speaker_volume > 0)
                        _volume = Convert.ToInt32(_item.speaker_volume * 10);

            if (Path.GetExtension(pAudioFileUrl) == ".wav")
                m_MediaType = eMediaType.WavFile;
            else if (Path.GetExtension(pAudioFileUrl) == ".mp3")
                m_MediaType = eMediaType.Mp3File;

            m_MediaFile = pAudioFileUrl;
            //axWindowsMediaPlayer.URL = pAudioFileUrl;
            //axWindowsMediaPlayer.Ctlcontrols.stop();
            //axWindowsMediaPlayer.settings.volume = _volume;

            trackBarControl.Properties.Minimum = 0;
            FileInfo info = new FileInfo(pAudioFileUrl);

            if (info.Length == 0) {
                MessageBox.Show("Audio file don't have any content.", "Can't play audio", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (IsMediaValidated())
            {
                if (m_MediaType == eMediaType.WavFile)
                    InitializeWavAudio();
                else
                    InitializeMp3Audio();

                if(!this.IsDisposed)
                    this.btnPlay_Click(null, null);
            }
        }
예제 #11
0
        public CallLogPlayer(string pAudioFileUrl)
        {
            int _volume = 50;
            /** /
            BrightPlatformEntities _efDbContext = new BrightPlatformEntities(UserSession.EntityConnection);
            audio_settings _item = _efDbContext.audio_settings.FirstOrDefault(i => i.user_id == UserSession.CurrentUser.UserId);
            if (_item != null)
                if (_item.speaker_volume != null)
                    if (_item.speaker_volume > 0)
                        _volume = Convert.ToInt32(_item.speaker_volume * 10);
            /**/

            if (Path.GetExtension(pAudioFileUrl) == ".wav")
                m_MediaType = eMediaType.WavFile;
            else if (Path.GetExtension(pAudioFileUrl) == ".mp3")
                m_MediaType = eMediaType.Mp3File;

            InitializeComponent();
            m_MediaFile = pAudioFileUrl;
            axWindowsMediaPlayer.URL = pAudioFileUrl;
            axWindowsMediaPlayer.Ctlcontrols.stop();
            axWindowsMediaPlayer.settings.volume = _volume;
            this.btnPlay_Click(null, null);
        }
예제 #12
0
        private void doListFocus(object param)
        {
            TreeViewItem tv = param as TreeViewItem;

            islinqRequest = false;
            if (tv == null)
            {
                String s = param as String;
                var    v = from entry in db.playlists
                           where (entry.Key == s)
                           select entry;

                Listdata = eMediaType.ALL;
                foreach (KeyValuePair <String, ObservableCollection <Media> > r in v)
                {
                    mediaList = new ObservableCollection <Media>(r.Value);
                    return;
                }
                return;
            }
            else
            {
                String header = tv.Header.ToString();
                if (header == "Current Playlist")
                {
                    Listdata  = eMediaType.ALL;
                    mediaList = new ObservableCollection <Media>(db.ListCurrent);
                }
                else if (header == "Musics")
                {
                    Listdata  = eMediaType.MUSIC;
                    mediaList = new ObservableCollection <Media>(db.ListSound);
                }
                else if (header == "Pictures")
                {
                    Listdata  = eMediaType.PICTURES;
                    mediaList = new ObservableCollection <Media>(db.ListPicture);
                }
                else if (header == "Videos")
                {
                    Listdata  = eMediaType.VIDEOS;
                    mediaList = new ObservableCollection <Media>(db.ListVideo);
                }
                #region linq_request
                else if (header == "Artist")
                {
                    var stuff = from entry in db.ListSound
                                group entry by entry.artist
                                into g
                                select new { Remainder = g.Key };
                    ObservableCollection <Media> ocm = new ObservableCollection <Media>();
                    foreach (var g in stuff)
                    {
                        Media m = new Media();
                        m.artist = g.Remainder;
                        m.type   = TestUserControl.eMediaType.SOUND;
                        ocm.Add(m);
                        mediaList = ocm;
                    }
                    islinqRequest = true;
                    medRequest    = "Artist";
                }
                else if (header == "Genre")
                {
                    var stuff = from entry in db.ListSound
                                group entry by entry.genre
                                into g
                                select new { Remainder = g.Key };
                    ObservableCollection <Media> ocm = new ObservableCollection <Media>();
                    foreach (var g in stuff)
                    {
                        Media m = new Media();
                        m.genre = g.Remainder;
                        m.type  = TestUserControl.eMediaType.SOUND;
                        ocm.Add(m);
                        mediaList = ocm;
                    }
                    islinqRequest = true;
                    medRequest    = "Genre";
                }
                else if (header == "Album")
                {
                    var stuff = from entry in db.ListSound
                                group entry by entry.album
                                into g
                                select new { Remainder = g.Key };
                    ObservableCollection <Media> ocm = new ObservableCollection <Media>();
                    foreach (var g in stuff)
                    {
                        Media m = new Media();
                        m.album = g.Remainder;
                        m.type  = TestUserControl.eMediaType.SOUND;
                        ocm.Add(m);
                        mediaList = ocm;
                    }
                    islinqRequest = true;
                    medRequest    = "Album";
                }
                #endregion
            }
        }
예제 #13
0
 private void findFilesInAllDir(string[] extension, DirMedia dmedia, eMediaType type)
 {
     foreach (directoryMedia dm in dmedia.directories)
     {
         foreach (string s in extension)
         {
             string[] filepath = Directory.GetFiles(dm.dir, s, SearchOption.AllDirectories);
             foreach (string pathToFile in filepath)
             {
                 listMedia.Add(new Media(pathToFile, type));
             }
         }
     }
 }
예제 #14
0
        public void loadPath(String path, int _nb, ObservableCollection<Media> _listinCurr)
        {
            if (File.Exists(path))
            {
                pause = true;
                TextPlay = "|>";
                listinCurr = _listinCurr;
                try
                {
                    TagLib.File tagfile = TagLib.File.Create(path);
                    String artist = tagfile.Tag.FirstArtist;
                    TagLib.Properties p = tagfile.Properties;
                    TagLib.MediaTypes mt = p.MediaTypes;
                    if (mt == TagLib.MediaTypes.Audio)
                    {
                        mediatype = eMediaType.SOUND;
                        db.addSound(path);
                        myMedElem.Source = new Uri(path);
                        nb = _nb;
                    }
                    else if (mt == TagLib.MediaTypes.Photo)
                    {
                        mediatype = eMediaType.PICTURE;
                        db.addPicture(path);

                        myMedElem.Source = new Uri(path);
                        pause = false;
                        TextPlay = "||";
                        myMedElem.Play();
                        nb = _nb;
                    }
                    else if ((p.MediaTypes & TagLib.MediaTypes.Video) != TagLib.MediaTypes.None)
                    {
                        mediatype = eMediaType.VIDEO;
                        db.addVideo(path);
                        myMedElem.Source = new Uri(path);
                        nb = _nb;
                    }
                }
                catch (TagLib.UnsupportedFormatException e)
                {

                }
            }
        }
예제 #15
0
 private void findFilesSingleDir(string[] extension, string path, eMediaType type)
 {
     foreach (string s in extension)
     {
         string[] filepath = Directory.GetFiles(path, s, SearchOption.AllDirectories);
         foreach (string pathToFile in filepath)
         {
             listMedia.Add(new Media(pathToFile, type));
         }
     }
 }
예제 #16
0
 public ucPlaylistModel(DatabasePlaylist ddb)
 {
     db = ddb;
     MusicsFocusCommand = new DelegateCommand(doListFocus, CanListFocus);
     RequestFocusCommand = new DelegateCommand(doRequestFocus, CanRequestFocus);
     OpenFile = new DelegateCommand(doOpenFile, CanOpenFile);
     Listdata = eMediaType.MUSIC;
     //            mediaList = new ObservableCollection<Media>(db.ListCurrent);
     CreatePlaylist = new DelegateCommand(doCreateList, CanCreateList);
     affAbout = new DelegateCommand(doAffAbout, CanAffAbout);
     islinqRequest = false;
     Actualizedico();
 }
예제 #17
0
 public DirMedia()
 {
     countDir = 0;
     type = eMediaType.NONE;
 }
예제 #18
0
 public EpisodeNamer(string path, EpisodeSearchResult search, eMediaType episodeType)
 {
     _path      = path;
     _search    = search;
     _mediaType = episodeType;
 }
예제 #19
0
 public void NotifyProcessedFile(eMediaType mediaType, string fileName)
 {
     _broker.Publish(mediaType.ToString(), fileName, "ConvertedMedia");
 }
예제 #20
0
 public directoryMedia(string nDir, eMediaType nType)
 {
     dir = nDir;
     type = nType;
 }
예제 #21
0
        private async Task <ProcessedEpisode> ProcessFoundEpisodeAsync(string path, EpisodeSearchResult episode, eMediaType mediaType)
        {
            var namer            = new EpisodeNamer(path, episode, mediaType);
            var finalDestination = await _episodeStore.SaveDownload(path, namer.FolderPath, namer.FileName);

            // Save.
            var processedEpisode = new ProcessedEpisode {
                EpisodeId = episode.Id, Source = path, Output = finalDestination
            };

            await UpdateOrAddToRepo(processedEpisode);

            _logger.LogInformation($"Processed Episode - FROM: (processorStore)/{path} | TO: (mediaStore)/{finalDestination}");

            return(processedEpisode);
        }
예제 #22
0
 public DirMedia(eMediaType typeMedia)
 {
     countDir = 0;
     type = typeMedia;
 }
예제 #23
0
        private void doListFocus(object param)
        {
            TreeViewItem tv = param as TreeViewItem;
            islinqRequest = false;
            if (tv == null)
            {
                String s = param as String;
                var v = from entry in db.playlists
                        where (entry.Key == s)
                        select entry;

                Listdata = eMediaType.ALL;
                foreach (KeyValuePair<String, ObservableCollection<Media>> r in v)
                {
                    mediaList = new ObservableCollection<Media>(r.Value);
                    return;
                }
                return;
           }
            else
            {
                String header = tv.Header.ToString();
                if (header == "Current Playlist")
                {
                    Listdata = eMediaType.ALL;
                    mediaList = new ObservableCollection<Media>(db.ListCurrent);
                }
                else if (header == "Musics")
                {
                    Listdata = eMediaType.MUSIC;
                    mediaList = new ObservableCollection<Media>(db.ListSound);
                }
                else if (header == "Pictures")
                {
                    Listdata = eMediaType.PICTURES;
                    mediaList = new ObservableCollection<Media>(db.ListPicture);
                }
                else if (header == "Videos")
                {
                    Listdata = eMediaType.VIDEOS;
                    mediaList = new ObservableCollection<Media>(db.ListVideo);
                }
                #region linq_request
                else if (header == "Artist")
                {
                    var stuff = from entry in db.ListSound
                                group entry by entry.artist
                                    into g
                                    select new { Remainder = g.Key };
                    ObservableCollection<Media> ocm = new ObservableCollection<Media>();
                    foreach (var g in stuff)
                    {
                        Media m = new Media();
                        m.artist = g.Remainder;
                        m.type = TestUserControl.eMediaType.SOUND;
                        ocm.Add(m);
                        mediaList = ocm;
                    }
                    islinqRequest = true;
                    medRequest = "Artist";
                }
                else if (header == "Genre")
                {
                    var stuff = from entry in db.ListSound
                                group entry by entry.genre
                                    into g
                                    select new { Remainder = g.Key };
                    ObservableCollection<Media> ocm = new ObservableCollection<Media>();
                    foreach (var g in stuff)
                    {
                        Media m = new Media();
                        m.genre = g.Remainder;
                        m.type = TestUserControl.eMediaType.SOUND;
                        ocm.Add(m);
                        mediaList = ocm;
                    }
                    islinqRequest = true;
                    medRequest = "Genre";
                }
                else if (header == "Album")
                {
                    var stuff = from entry in db.ListSound
                                group entry by entry.album
                                    into g
                                    select new { Remainder = g.Key };
                    ObservableCollection<Media> ocm = new ObservableCollection<Media>();
                    foreach (var g in stuff)
                    {
                        Media m = new Media();
                        m.album = g.Remainder;
                        m.type = TestUserControl.eMediaType.SOUND;
                        ocm.Add(m);
                        mediaList = ocm;
                    }
                    islinqRequest = true;
                    medRequest = "Album";
                }
                #endregion
            }
        }