From 820ebc704e36786406b0960929c6ca53a232eb9f Mon Sep 17 00:00:00 2001 From: trizen Date: Sat, 16 May 2020 10:32:30 +0300 Subject: [PATCH] Changed the default cache direction from /tmp/straw-viewer to ~/.cache/straw-viewer. (fixes https://github.com/trizen/straw-viewer/issues/11) Also removed the `captions_dir` config-option. Closed-captions are now downloaded inside the cache directory. --- bin/gtk-straw-viewer | 7 +++---- bin/straw-viewer | 11 ++++------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/bin/gtk-straw-viewer b/bin/gtk-straw-viewer index f266bab..bbd50ff 100755 --- a/bin/gtk-straw-viewer +++ b/bin/gtk-straw-viewer @@ -215,8 +215,7 @@ my %CONFIG = ( srt_languages => ['en', 'es'], get_captions => 1, auto_captions => 0, - captions_dir => catdir(tmpdir(), 'straw-viewer'), - cache_dir => catdir(tmpdir(), 'straw-viewer'), + cache_dir => undef, # Others env_proxy => 1, @@ -459,7 +458,7 @@ if (not defined $CONFIG{cache_dir}) { $CONFIG{cache_dir} = catdir($cache_dir, 'straw-viewer'); } -foreach my $path($CONFIG{cache_dir}, $CONFIG{captions_dir}) { +foreach my $path($CONFIG{cache_dir}) { next if -d $path; require File::Path; File::Path::make_path($path) @@ -3005,7 +3004,7 @@ sub get_streaming_url { require WWW::StrawViewer::GetCaption; my $yv_cap = WWW::StrawViewer::GetCaption->new( auto_captions => $CONFIG{auto_captions}, - captions_dir => $CONFIG{captions_dir}, + captions_dir => $CONFIG{cache_dir}, captions => $captions, languages => $CONFIG{srt_languages}, ); diff --git a/bin/straw-viewer b/bin/straw-viewer index 10fb764..45d50b9 100755 --- a/bin/straw-viewer +++ b/bin/straw-viewer @@ -206,8 +206,7 @@ my %CONFIG = ( get_captions => 1, auto_captions => 0, copy_caption => 0, - captions_dir => catdir(tmpdir(), 'straw-viewer'), - cache_dir => catdir(tmpdir(), 'straw-viewer'), + cache_dir => undef, # API api_host => "https://invidio.us", @@ -544,7 +543,7 @@ sub load_config { dump_configuration($config_file) if $update_config; -foreach my $path($CONFIG{cache_dir}, $CONFIG{captions_dir}) { +foreach my $path($CONFIG{cache_dir}) { next if -d $path; require File::Path; File::Path::make_path($path) @@ -770,7 +769,6 @@ usage: $execname [options] ([url] | [keywords]) * Closed-captions --get-captions! : download closed-captions for videos --auto-captions! : include or exclude auto-generated captions - --captions-dir=s : directory where to save the .srt files * Config --config=s : configuration file @@ -1621,7 +1619,6 @@ sub parse_arguments { 'get-captions|get_captions!' => \$opt{get_captions}, 'auto-captions|auto_captions!' => \$opt{auto_captions}, 'copy-caption|copy_caption!' => \$opt{copy_caption}, - 'captions-dir|captions_dir=s' => \$opt{captions_dir}, 'skip-if-exists|skip_if_exists!' => \$opt{skip_if_exists}, 'downloads-dir|download-dir=s' => \$opt{downloads_dir}, 'fat32safe!' => \$opt{fat32safe}, @@ -3024,7 +3021,7 @@ sub get_streaming_url { require WWW::StrawViewer::GetCaption; my $yv_cap = WWW::StrawViewer::GetCaption->new( auto_captions => $opt{auto_captions}, - captions_dir => $opt{captions_dir}, + captions_dir => $opt{cache_dir}, captions => $captions, languages => $CONFIG{srt_languages}, ); @@ -3285,7 +3282,7 @@ sub download_video { } } - # Copy the .srt file from captions-dir to downloads-dir + # Copy the .srt file to downloads-dir if ( $opt{copy_caption} and -e $video_filename and defined($streaming->{srt_file})