Skip to content

Commit c6178c1

Browse files
committed
clean up handling of internal options in PVR
Consolidated preservation of internal options in PVR::run.
1 parent 4efb728 commit c6178c1

File tree

1 file changed

+37
-38
lines changed

1 file changed

+37
-38
lines changed

get_iplayer

+37-38
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,6 @@ my @argv_save = @ARGV;
276276
$opt_pre->parse( 1 );
277277
@ARGV = @argv_save;
278278

279-
# internal ffmpeg options
280-
my @ffmpeg_opts = ('ffmpegversion', 'ffmpeg25', 'ffmpeg30', 'ffmpegav', 'ffmpegxx');
281-
282279
# set encodings ASAP
283280
my @encoding_opts = ('encodinglocale', 'encodinglocalefs', 'encodingconsoleout', 'encodingconsolein');
284281
foreach ( @encoding_opts ) {
@@ -689,6 +686,7 @@ sub init_search {
689686
} else {
690687
unless ( $opt->{proxy} ) {
691688
$opt->{proxy} = $ENV{HTTP_PROXY} || $ENV{http_proxy};
689+
delete $opt->{proxy} unless defined $opt->{proxy};
692690
}
693691
logger "INFO: Using proxy: $opt->{proxy}\n" if $opt->{proxy};
694692
}
@@ -5681,11 +5679,11 @@ sub modelist {
56815679
$mlist =~ s/\bhls\b/hlsaac/g if $mlist !~ /hlsaac/;
56825680
$mlist =~ s/dash/daf/g;
56835681
}
5684-
if ( $mlist ne $mlist_orig && ! $opt->{modewarn} ) {
5682+
if ( $mlist ne $mlist_orig && ! $opt->{nowarnmoderemap} ) {
56855683
main::logger "WARNING: Some recording modes were remapped to new values\n";
56865684
main::logger "WARNING: Input mode list remapped from '$mlist_orig' to '$mlist'\n";
56875685
main::logger "WARNING: Please update your preferences\n";
5688-
$opt->{modewarn} = 1;
5686+
$opt->{nowarnmoderemap} = 1;
56895687
}
56905688
# Deal with fallback modes and expansions
56915689
# Generic aliases
@@ -5832,10 +5830,10 @@ sub ffmpeg_init {
58325830
if ( $ffvs =~ /^(\d+\.\d+)/i ) {
58335831
$ffvn = $1;
58345832
if ( $ffvn >= 3.0 ) {
5835-
$opt->{ffmpeg30} = 1;
5836-
$opt->{ffmpeg25} = 1;
5833+
$opt->{myffmpeg30} = 1;
5834+
$opt->{myffmpeg25} = 1;
58375835
} elsif ( $ffvn >= 2.5 ) {
5838-
$opt->{ffmpeg25} = 1;
5836+
$opt->{myffmpeg25} = 1;
58395837
} elsif ( $ffvn < 1.0 ) {
58405838
$opt->{ffmpegobsolete} = 1 unless defined $opt->{ffmpegobsolete};
58415839
}
@@ -5845,20 +5843,20 @@ sub ffmpeg_init {
58455843
main::logger "INFO: ffmpeg version string = ".($ffvs || "not found")."\n";
58465844
main::logger "INFO: ffmpeg version number = ".($ffvn || "unknown")."\n";
58475845
}
5848-
$opt->{ffmpegversion} = $ffvn;
5849-
unless ( $opt->{ffmpegversion} ) {
5846+
$opt->{myffmpegversion} = $ffvn;
5847+
unless ( $opt->{myffmpegversion} ) {
58505848
if ( $bin->{ffmpeg} =~ /avconv/ || $ffout =~ /avconv/ ) {
58515849
delete $opt->{ffmpegobsolete};
5852-
$opt->{ffmpegav} = 1;
5850+
$opt->{myffmpegav} = 1;
58535851
}
5854-
$opt->{ffmpegxx} = 1;
5852+
$opt->{myffmpegxx} = 1;
58555853
}
58565854
# override ffmpeg checks
58575855
if ( $opt->{ffmpegforce} ) {
5858-
$opt->{ffmpeg30} = 1;
5859-
$opt->{ffmpeg25} = 1;
5860-
delete $opt->{ffmpegav};
5861-
delete $opt->{ffmpegxx};
5856+
$opt->{myffmpeg30} = 1;
5857+
$opt->{myffmpeg25} = 1;
5858+
delete $opt->{myffmpegav};
5859+
delete $opt->{myffmpegxx};
58625860
}
58635861
delete $binopts->{ffmpeg};
58645862
push @{ $binopts->{ffmpeg} }, ();
@@ -6432,16 +6430,16 @@ sub download {
64326430
}
64336431
# cannot convert hvf with avconv or ffmpeg < 2.5
64346432
if ( $mode =~ /^hvf/ && ! $opt->{raw} ) {
6435-
if ( $opt->{ffmpegav} ) {
6433+
if ( $opt->{myffmpegav} ) {
64366434
main::logger "WARNING: avconv does not support conversion of hvf downloads to MP4 - not converting .ts file\n";
64376435
$opt->{raw} = 1;
6438-
} elsif ( $opt->{ffmpegxx} ) {
6436+
} elsif ( $opt->{myffmpegxx} ) {
64396437
main::logger "WARNING: Unable to determine ffmpeg version - MP4 conversion for hvf downloads may fail\n";
6440-
} elsif ( ! $opt->{ffmpeg25} ) {
6441-
main::logger "WARNING: Your version of ffmpeg ($opt->{ffmpegversion}) does not support conversion of hvf downloads to MP4 - not converting .ts file\n";
6438+
} elsif ( ! $opt->{myffmpeg25} ) {
6439+
main::logger "WARNING: Your version of ffmpeg ($opt->{myffmpegversion}) does not support conversion of hvf downloads to MP4 - not converting .ts file\n";
64426440
$opt->{raw} = 1;
64436441
}
6444-
if ( $opt->{ffmpegav} || $opt->{ffmpegxx} || ! $opt->{ffmpeg25} ) {
6442+
if ( $opt->{myffmpegav} || $opt->{myffmpegxx} || ! $opt->{myffmpeg25} ) {
64456443
main::logger "WARNING: ffmpeg 2.5 or higher is required to convert hvf downloads to MP4\n";
64466444
main::logger "WARNING: Use --raw to bypass MP4 conversion and retain .ts file\n";
64476445
main::logger "WARNING: Use --ffmpeg-force to override checks and force MP4 conversion attempt\n";
@@ -6454,16 +6452,16 @@ sub download {
64546452
}
64556453
# cannot convert dvf with avconv or ffmpeg < 3.0
64566454
if ( $mode =~ /^dvf/ && ! $opt->{raw} ) {
6457-
if ( $opt->{ffmpegav} ) {
6455+
if ( $opt->{myffmpegav} ) {
64586456
main::logger "WARNING: avconv does not support conversion of dvf downloads to MP4 - not converting .m4a and .m4v files\n";
64596457
$opt->{raw} = 1;
6460-
} elsif ( $opt->{ffmpegxx} ) {
6458+
} elsif ( $opt->{myffmpegxx} ) {
64616459
main::logger "WARNING: Unable to determine ffmpeg version - MP4 conversion for dvf downloads may fail\n";
6462-
} elsif ( ! $opt->{ffmpeg30} ) {
6463-
main::logger "WARNING: Your version of ffmpeg ($opt->{ffmpegversion}) does not support conversion of dvf downloads to MP4 - not converting .m4a and .m4v files\n";
6460+
} elsif ( ! $opt->{myffmpeg30} ) {
6461+
main::logger "WARNING: Your version of ffmpeg ($opt->{myffmpegversion}) does not support conversion of dvf downloads to MP4 - not converting .m4a and .m4v files\n";
64646462
$opt->{raw} = 1;
64656463
}
6466-
if ( $opt->{ffmpegav} || $opt->{ffmpegxx} || ! $opt->{ffmpeg30} ) {
6464+
if ( $opt->{myffmpegav} || $opt->{myffmpegxx} || ! $opt->{myffmpeg30} ) {
64676465
main::logger "WARNING: ffmpeg 3.0 or higher is required to convert dvf downloads to MP4\n";
64686466
main::logger "WARNING: Use --raw to bypass MP4 conversion and retain .m4a and .m4v files\n";
64696467
main::logger "WARNING: Use --ffmpeg-force to override checks and force MP4 conversion attempt\n";
@@ -7799,12 +7797,13 @@ sub run {
77997797
main::print_divider;
78007798
# Clear then Load options for specified pvr search name
78017799
my $opt_backup;
7802-
foreach ( @encoding_opts, @ffmpeg_opts ) {
7803-
$opt_backup->{$_} = $opt->{$_} if $opt->{$_};
7800+
my @backup_opts = grep /^(encoding|myap|myffmpeg|nowarn)/, keys %{$opt};
7801+
foreach ( @backup_opts ) {
7802+
$opt_backup->{$_} = $opt->{$_} if defined $opt->{$_};
78047803
}
78057804
my @search_args = $pvr->load_options($name);
7806-
foreach ( @encoding_opts, @ffmpeg_opts ) {
7807-
$opt->{$_} = $opt_backup->{$_} if $opt_backup->{$_};
7805+
foreach ( @backup_opts ) {
7806+
$opt->{$_} = $opt_backup->{$_} if defined $opt_backup->{$_};
78087807
}
78097808

78107809
## Display all options used for this pvr search
@@ -8295,10 +8294,10 @@ sub ap_init {
82958294
}
82968295
# determine AtomicParsley features
82978296
my $ap_help = `"$bin->{atomicparsley}" --help 2>&1`;
8298-
$opt->{tag_hdvideo} = 1 if $ap_help =~ /--hdvideo/;
8299-
$opt->{tag_longdesc} = 1 if $ap_help =~ /--longdesc/;
8300-
$opt->{tag_longdescription} = 1 if $ap_help =~ /--longDescription/;
8301-
$opt->{tag_utf8} = 1 if ! defined($opt->{tag_utf8}) and ( $^O ne "MSWin32" or $bin->{atomicparsley} =~ /-utf8/i );
8297+
$opt->{myaphdvideo} = 1 if $ap_help =~ /--hdvideo/;
8298+
$opt->{myaplongdesc} = 1 if $ap_help =~ /--longdesc/;
8299+
$opt->{myaplongdescription} = 1 if $ap_help =~ /--longDescription/;
8300+
$opt->{myaputf8} = 1 if ! defined($opt->{tag_utf8}) and ( $^O ne "MSWin32" or $bin->{atomicparsley} =~ /-utf8/i );
83028301
$ap_check = 1;
83038302
}
83048303

@@ -8315,7 +8314,7 @@ sub tag_file_mp4 {
83158314
# handle embedded quotes
83168315
tags_escape_quotes($tags);
83178316
# encode metadata for atomicparsley
8318-
tags_encode($tags) unless $opt->{tag_utf8};
8317+
tags_encode($tags) unless $opt->{tag_utf8} || $opt->{myaputf8};
83198318
# build atomicparsley command
83208319
my @cmd = (
83218320
$bin->{atomicparsley},
@@ -8341,16 +8340,16 @@ sub tag_file_mp4 {
83418340
# add descriptions to audio podcasts and video
83428341
if ( $tags->{is_video} || $tags->{is_podcast}) {
83438342
push @cmd, ('--description', $tags->{description} );
8344-
if ( $opt->{tag_longdescription} ) {
8343+
if ( $opt->{myaplongdescription} ) {
83458344
push @cmd, ( '--longDescription', $tags->{longDescription} );
8346-
} elsif ( $opt->{tag_longdesc} ) {
8345+
} elsif ( $opt->{myaplongdesc} ) {
83478346
push @cmd, ( '--longdesc', $tags->{longDescription} );
83488347
}
83498348
}
83508349
# video only
83518350
if ( $tags->{is_video} ) {
83528351
# all video
8353-
push @cmd, ( '--hdvideo', $tags->{hdvideo} ) if $opt->{tag_hdvideo};
8352+
push @cmd, ( '--hdvideo', $tags->{hdvideo} ) if $opt->{myaphdvideo};
83548353
# tv only
83558354
if ( $tags->{is_tvshow} ) {
83568355
push @cmd, (

0 commit comments

Comments
 (0)