コード例 #1
0
        public void scan_file_one_time( IFileItem fitem )
        {
            var mibin = Environment.CurrentDirectory + "\\Library\\MediaInfo.exe";

            var output = Factory.Instance.Utils.get_process_output( mibin, "\"" + fitem.Path + "\"", 5000 );

            if ( output.Contains( "Duration" ) )
            {
                // ReSharper disable once ObjectCreationAsStatement
                new MediaInfo( fitem, output );
            }
        }
コード例 #2
0
        public bool OpenFile()
        {
            //CurrentFile = new FileItem();
            //CurrentFile.Name = "Example File";
            //CurrentFile.Properties.Add(new PropertyItem() { Name = "Property one", Value = 0 });
            //CurrentFile.Properties.Add(new PropertyItem() { Name = "Property two", Value = 0 });
            //CurrentFile.Properties.Add(new PropertyItem() { Name = "Property three", Value = 0 });
            //CurrentFile.Properties.Add(new PropertyItem() { Name = "Property four", Value = 0 });

            using (FileStream fs = new FileStream("data.dat", FileMode.Open, FileAccess.Read))
            {
                BinaryFormatter bf = new BinaryFormatter();
                CurrentFile = bf.Deserialize(fs) as FileItem;
                fs.Close();
            }

            return true;
        }
コード例 #3
0
        private void SeriesTreeView_SelectedItemChanged( object sender, RoutedPropertyChangedEventArgs< object > e )
        {
            try
            {
                if ( this.SeriesTreeView.SelectedItem == null )
                {
                    return;
                }

                var directory = this.SeriesTreeView.SelectedItem as IDirectoryItem;
                var file = this.SeriesTreeView.SelectedItem as IFileItem;

                if ( directory != null )
                {
                    var fname = Factory.Instance.ItemProvider.get_series_name_from_folder( directory );
                    var series = Factory.Instance.Tvdb?.get_series_by_name( fname );

                    if ( series != null )
                    {
                        this.TvdbTab.Content = new UserControlSeriesViewer( series );
                    }
                    else
                    {
                        this.TvdbTab.Content = new UserControlTvdbMissing();
                    }
                }

                if ( file == null )
                {
                    return;
                }

                var name = Factory.Instance.ItemProvider.get_series_name_from_file( file );

                if ( name != null )
                {
                    var series = Factory.Instance.Tvdb?.get_series_by_name( name );
                    if ( series != null )
                    {
                        this.TvdbTab.Content = new UserControlSeriesViewer( series );
                    }
                    else
                    {
                        this.TvdbTab.Content = new UserControlTvdbMissing();
                    }
                }
                else
                {
                    this.TvdbTab.Content = new UserControlTvdbMissing();
                }

                if ( file.Missing )
                {
                    this.MediaTab.Content = new UserControlTvdbMissing();
                    return;
                }

                var mw = new MediaInfoWorker();
                mw.scan_file_one_time( file );

                if ( file.Mediainfo == null )
                {
                    this.MediaTab.Content = new UserControlTvdbMissing();
                    return;
                }

                this._item = file;

                var fetchMetaDataWorker = new BackgroundWorker();
                fetchMetaDataWorker.DoWork += this.fetchMetaDataWorker_DoWork;
                fetchMetaDataWorker.RunWorkerCompleted += this.fetchMetaDataWorker_RunWorkerCompleted;
                fetchMetaDataWorker.RunWorkerAsync();
            }
            catch ( Exception ex )
            {
                Factory.Instance.LogLines.Enqueue( ex.Message );
                Factory.Instance.LogLines.Enqueue( ex.StackTrace );
            }
        }
コード例 #4
0
ファイル: Project.cs プロジェクト: JadeHub/Jade
 private void AddSourceFile(IFileItem f)
 {
     _allSourceFiles.Add(f);            
 }
コード例 #5
0
 private bool IsArchive(IFileItem item)
 {
     return item.Path.EndsWith(".tar.gz") ||
                        item.Path.EndsWith (".tar.bz2") ||
                        item.Path.EndsWith (".tar") ;
 }
コード例 #6
0
        public int CompareTo(IFileItem other)
        {
            if (other == null)
                return 1;

            var dateComparison = this.Date.CompareTo(other.Date);
            if (dateComparison != 0)
                return dateComparison;

            var filePathComparison = String.Compare(this.FilePath, other.FilePath, StringComparison.Ordinal);
            if (filePathComparison != 0)
                return filePathComparison;

            return this.Size.CompareTo(other.Size);
        }
コード例 #7
0
        private bool IsValidFormat(IFileItem item)
        {
            // Supported uploading format by Google Docs
            //
            // Detailed info: http://documents.google.com/support/presentations/bin/answer.py?answer=50092
            //                http://documents.google.com/support/presentations/bin/answer.py?answer=37603

            return new Regex (ExtPattern, RegexOptions.Compiled).IsMatch (item.Path);
        }
コード例 #8
0
        private void scan_file( IFileItem fitem )
        {
            this._scannedItemsCount += 1;
            var mibin = Environment.CurrentDirectory + "\\Library\\MediaInfo.exe";

            var output = Factory.Instance.Utils.get_process_output( mibin, "\"" + fitem.Path + "\"" );

            if ( output.Contains( "Duration" ) )
            {
                // ReSharper disable once ObjectCreationAsStatement
                new MediaInfo( fitem, output );
                Factory.Instance.LogLines.Enqueue( "Scanned media info successfuly : " + fitem.Path );
            }
            else
            {
                this._brokenFiles.Enqueue( fitem );
                this._worker.ReportProgress( 1 );
                Factory.Instance.LogLines.Enqueue( "Media metadata unreadable : " + fitem.Path );
            }
            this._worker.ReportProgress( 1 );
        }
コード例 #9
0
 protected override bool SupportsItem(IFileItem item)
 {
     return(Directory.Exists(GetPath(item)));
 }
コード例 #10
0
 protected override string GetTargetPath(IFileItem item)
 {
     return(Path.Combine(this.Configuration.GetTransferLocation(this.TransferLocationName).RootPath, this.TransferLocationSubPath, item.RelativePath));
 }
コード例 #11
0
 protected override string GetSourcePath(IFileItem item)
 {
     return(Path.Combine(GetSyncFolderDefinition().RootPath, item.RelativePath));
 }
コード例 #12
0
 public GdalInfoModel(IFileItem item)
 {
     Filename   = item.Filename;
     Datasource = item;
 }
コード例 #13
0
        private void convert_file( IFileItem fitem )
        {
            this._convertedItemsCount += 1;

            var mi = Environment.CurrentDirectory + "\\Library\\ffmpeg.exe";
            var arguments = "-y -v info -i \"" + fitem.Path.Replace( "\\", "/" ) + "\" -c:a copy -c:s mov_text -c:v mpeg4 -f mp4 \"" + fitem.Parent.Path.Replace( "\\", "/" ) + "/" + fitem.ShortName + ".mp4\"";
            var objpath = Factory.Instance.AppDataFolder + "\\ffmpegconvert.bat";

            if ( Factory.Instance.Utils.write_file( objpath, "@echo off" + Environment.NewLine + "\"" + mi + "\" " + arguments + Environment.NewLine + "EXIT /B %errorlevel%" ) == false )
            {
                return;
            }

            var returncode = Factory.Instance.Utils.run_process_foreground( objpath, "" );

            if ( returncode > 0 )
            {
                this._unconvertedFiles.Enqueue( fitem );
                Factory.Instance.LogLines.Enqueue( "FFmpeg convert problem : " + fitem.Path );
            }
            else
            {
                Factory.Instance.LogLines.Enqueue( "FFmpeg convert ok : " + fitem.Path );
            }

            this._worker.ReportProgress( 1 );
        }
コード例 #14
0
 public FfmpegConvertWorker( IFileItem file )
 {
     this._unconvertedFiles = new ConcurrentQueue< IFileItem >();
     this._fileitem = file;
 }
コード例 #15
0
 public FileItemViewModel(IFileItem content)
 {
     Content = content ?? throw new ArgumentNullException(nameof(content));
 }
コード例 #16
0
ファイル: UploadPool.cs プロジェクト: jrudolph/do-plugins
 public void EnqueueUpload(IFileItem file)
 {
     lock (locker)
     {
         taskQ.Enqueue (file);
         Monitor.PulseAll (locker);
     }
 }
コード例 #17
0
ファイル: MediaInfo.cs プロジェクト: dmzoneill/filebotpp
 public MediaInfo( IFileItem file, string mediainfo )
 {
     this.parse_media_info( mediainfo );
     file.Mediainfo = this;
     file.Update();
 }
コード例 #18
0
 public MediaInfoWorker( IFileItem file )
 {
     this._brokenFiles = new ConcurrentQueue< IFileItem >();
     this._fileitem = file;
 }
コード例 #19
0
 public static Task <(Func <ImageSource> Small, Func <ImageSource> Large)> BookIconsExplorer(IFileItem file, CancellationToken cancel, Windows.UI.Core.CoreDispatcher dispatcher)
 {
     return(BookIcons(file, cancel, dispatcher, new Uri("ms-appx:///res/Icon/icon_book_s.png"), new Uri("ms-appx:///res/Icon/icon_book_l.png")));
 }
コード例 #20
0
 private bool IsImageFile(IFileItem file)
 {
     return imageMimeTypeMap.ContainsKey (Path.GetExtension (file.Path));
 }
コード例 #21
0
 private bool IsImageFile(IFileItem file)
 {
     return image_mime_type_mapping.ContainsKey (Path.GetExtension (file.Path).ToLower ());
 }
コード例 #22
0
		internal static void DropFile (SolutionFolder folder, IFileItem fileItem, DragOperation operation)
		{
			FilePath dest = folder.BaseDirectory.Combine (fileItem.FileName.FileName);
			if (operation == DragOperation.Copy) {
				if (dest == fileItem.FileName)
					dest = ProjectOperations.GetTargetCopyName (dest, false);
				FileService.CopyFile (fileItem.FileName, dest);
			}
			else {
				var pf = fileItem as ProjectFile;
				if (pf != null && pf.Project != null)
					pf.Project.Files.Remove (pf);
				var fn = fileItem as SolutionFolderFileNode;
				if (fn != null) {
					if (fn.Parent == folder)
						return;
					fn.Parent.Files.Remove (fileItem.FileName);
				}
				FileService.MoveFile (fileItem.FileName, dest);
			}
			folder.Files.Add (dest);
		}
コード例 #23
0
 public FfmpegCorruptWorker( IFileItem file )
 {
     this._brokenFiles = new ConcurrentQueue< IFileItem >();
     this._fileitem = file;
 }
コード例 #24
0
 private void ExtractArchive( IFileItem archive, IFileItem where)
 {
     if ( archive.Name.EndsWith ("tar.gz"))
                         Process.Start ("tar", string.Format ("-xzf {0} -C {1}", EscapeString(archive.Path), EscapeString(where.Path)));
                 else if ( archive.Name.EndsWith ("tar.bz2"))
                         Process.Start ("tar", string.Format ("-xjf {0} -C {1}", EscapeString(archive.Path), EscapeString(where.Path)));
                 else if (archive.Name.EndsWith ("tar"))
                         Process.Start ("tar", string.Format ("-xf {0} -C {1}", EscapeString (archive.Path), EscapeString(where.Path)));
 }
コード例 #25
0
        private void scan_file( IFileItem fitem )
        {
            this._scannedItemsCount += 1;

            var mi = Environment.CurrentDirectory + "\\Library\\ffmpeg.exe";
            var arguments = "-y -v info -t 5 -i \"" + fitem.Path.Replace( "\\", "/" ) + "\" -c:a copy -c:s mov_text -c:v mpeg4 -f mp4 test.mp4";

            if ( Factory.Instance.Utils.write_file( Factory.Instance.AppDataFolder + "\\ffmpeg.bat", "@echo off" + Environment.NewLine + "\"" + mi + "\" " + arguments + Environment.NewLine + "EXIT /B %errorlevel%" ) == false )
            {
                return;
            }

            var output = Factory.Instance.Utils.run_process_background( Factory.Instance.AppDataFolder + "\\ffmpeg.bat", "" );

            if ( output > 0 )
            {
                this._brokenFiles.Enqueue( fitem );
                Factory.Instance.LogLines.Enqueue( "FFmpeg problem : " + fitem.Path );
            }
            else
            {
                Factory.Instance.LogLines.Enqueue( "FFmpeg looks ok : " + fitem.Path );
            }
            this._worker.ReportProgress( 1 );
        }
コード例 #26
0
		internal static void DropFile (SolutionFolder folder, IFileItem fileItem, DragOperation operation)
		{
			FilePath dest = folder.BaseDirectory.Combine (fileItem.FileName.FileName);
			if (operation == DragOperation.Copy)
				FileService.CopyFile (fileItem.FileName, dest);
			else
				FileService.MoveFile (fileItem.FileName, dest);
			folder.Files.Add (dest);
		}
コード例 #27
0
ファイル: SeriesAnalyzer.cs プロジェクト: dmzoneill/filebotpp
        private void clean_series_season_files_check_episode_name( IDirectoryItem directory, IItem subdirectory, IFileItem item )
        {
            if ( Factory.Instance.Tvdb == null )
            {
                return;
            }

            var cSeasonNum = int.Parse( subdirectory.FullName.Substring( 7 ).Trim() );

            var series = Factory.Instance.Tvdb.get_series_by_name( directory.FullName );

            if ( series == null )
            {
                return;
            }

            if ( series.has_seasons( cSeasonNum ) == false )
            {
                return;
            }

            var season = series.get_season( cSeasonNum );
            var episodes = season.get_episodes();

            var clean = false;

            foreach ( var episode in episodes )
            {
                var epnameclean = episode.get_episode_name().ToLower();
                epnameclean = epnameclean.Replace( ":", "" );
                epnameclean = epnameclean.Replace( "?", "" );
                epnameclean = Regex.Replace( epnameclean, ".+", "." );

                if ( item.FullName.ToLower().Contains( epnameclean ) )
                {
                    clean = true;
                    break;
                }
            }

            if ( clean == false )
            {
                Factory.Instance.ItemProvider.BadNameFiles.Enqueue( new BadNameUpdate {Directory = directory, File = item, SuggestName = ""} );
            }
        }
コード例 #28
0
ファイル: Project.cs プロジェクト: JadeHub/Jade
 private void RemoveSourceFile(IFileItem f)
 {
     _allSourceFiles.Remove(f);            
 }
コード例 #29
0
ファイル: SeriesAnalyzer.cs プロジェクト: dmzoneill/filebotpp
        private void clean_series_season_file_check_extra( IDirectoryItem directory, IItem subdirectory, IFileItem item )
        {
            if ( Factory.Instance.Tvdb == null )
            {
                return;
            }

            var cSeasonNum = int.Parse( subdirectory.FullName.Substring( 7 ).Trim() );

            var series = Factory.Instance.Tvdb.get_series_by_name( directory.FullName );

            if ( series == null )
            {
                return;
            }

            if ( series.has_seasons( cSeasonNum ) == false )
            {
                return;
            }

            const string stest1 = @".*?([0-9]+)x([0-9]{2})";
            const string stest2 = @"([0-9]+)xSpecial\s+?([0-9]+)";

            var match1 = Regex.Match( item.FullName, stest1 );
            var match2 = Regex.Match( item.FullName, stest2 );

            var epint = match1.Success ? match1.Groups[ 2 ].Value : match2.Groups[ 2 ].Value;

            if ( series.get_season( cSeasonNum ).get_episodes().Any( episode => episode.get_episode_num() == int.Parse( epint ) ) )
            {
                return;
            }

            Factory.Instance.ItemProvider.ExtraFiles.Enqueue( new ExtraFileUpdate {Directory = directory, File = item} );
        }
コード例 #30
0
ファイル: UploadAction.cs プロジェクト: jrudolph/do-plugins
 bool FileIsPicture(IFileItem item)
 {
     return FileIsPicture (item.Path);
 }
コード例 #31
0
        private async Task OnFileWatcher(IFileItem file, object obj)
        {
            ApiHubFile apiHubFile = new ApiHubFile(file);

            TriggeredFunctionData input = new TriggeredFunctionData
            {
                TriggerValue = apiHubFile
            };

            var functionResult = await _executor.TryExecuteAsync(input, CancellationToken.None);

            string pollStatus = null;
            var    uri        = obj as Uri;

            if (uri != null)
            {
                pollStatus = uri.AbsoluteUri;
            }
            else
            {
                pollStatus = obj.ToString();
            }

            if (functionResult.Succeeded)
            {
                // If function successfully completes then the next poll Uri will be logged in an Azure Blob.
                var status = new ApiHubStatus
                {
                    PollUrl = pollStatus
                };

                await SetNextPollStatusAsync(status);
            }
            else
            {
                var status = await GetLastPollStatusAsync();

                if (status == null)
                {
                    status = new ApiHubStatus();
                }

                if (status.RetryCount < this._apiHubConfig.MaxFunctionExecutionRetryCount)
                {
                    status.RetryCount++;
                    _trace.Error(string.Format("Function {0} failed to successfully process file {1}. Number of retries: {2}. ", _functionName, apiHubFile.Path, status.RetryCount));

                    await SetNextPollStatusAsync(status);
                    await OnFileWatcher(file, obj);
                }
                else
                {
                    // The maximum retries for the function execution has reached. The file info will be added to the poison queue and the next poll status will be updated to skip the file.
                    status.PollUrl    = pollStatus;
                    status.RetryCount = 0;
                    _trace.Error(string.Format("Function {0} failed to successfully process file {1} after max allowed retries of {2}. The file info will be moved to queue {3}.", _functionName, apiHubFile.Path, this._apiHubConfig.MaxFunctionExecutionRetryCount, PoisonQueueName));

                    await MoveToPoisonQueueAsync(apiHubFile);
                    await SetNextPollStatusAsync(status);
                }
            }
        }