Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Changed the default cache direction from /tmp/straw-viewer to ~/.cach…
Browse files Browse the repository at this point in the history
…e/straw-viewer. (fixes #11)

Also removed the `captions_dir` config-option. Closed-captions are now downloaded inside the cache directory.
  • Loading branch information
trizen committed May 16, 2020
1 parent c025084 commit 820ebc7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
7 changes: 3 additions & 4 deletions bin/gtk-straw-viewer
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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},
);
Expand Down
11 changes: 4 additions & 7 deletions bin/straw-viewer
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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},
);
Expand Down Expand Up @@ -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})
Expand Down

0 comments on commit 820ebc7

Please sign in to comment.