aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/gtk-straw-viewer14
-rwxr-xr-xbin/straw-viewer16
-rw-r--r--lib/WWW/StrawViewer.pm3
-rw-r--r--lib/WWW/StrawViewer/Channels.pm5
4 files changed, 21 insertions, 17 deletions
diff --git a/bin/gtk-straw-viewer b/bin/gtk-straw-viewer
index 432f31f..b244978 100755
--- a/bin/gtk-straw-viewer
+++ b/bin/gtk-straw-viewer
@@ -218,10 +218,10 @@ my %CONFIG = (
# Subtitle options
srt_languages => ['en', 'es'],
- captions_dir => tmpdir(),
get_captions => 1,
auto_captions => 0,
- cache_dir => undef, # will be defined later
+ captions_dir => catdir(tmpdir(), 'straw-viewer'),
+ cache_dir => catdir(tmpdir(), 'straw-viewer'),
# Others
env_proxy => 1,
@@ -464,11 +464,11 @@ if (not defined $CONFIG{cache_dir}) {
$CONFIG{cache_dir} = catdir($cache_dir, 'straw-viewer');
}
-# Create the cache directory (if needed)
-if (not -d $CONFIG{cache_dir}) {
+foreach my $path($CONFIG{cache_dir}, $CONFIG{captions_dir}) {
+ next if -d $path;
require File::Path;
- File::Path::make_path($CONFIG{cache_dir})
- or warn "[!] Can't create dir `$CONFIG{cache_dir}': $!";
+ File::Path::make_path($path)
+ or warn "[!] Can't create path <<$path>>: $!";
}
{
@@ -2524,7 +2524,7 @@ sub display_results {
#use Data::Dump qw(pp);
#pp $items;
- if (ref($items) eq 'HASH' and $items->{type} eq 'playlist') {
+ if (ref($items) eq 'HASH') {
$items = $items->{videos};
}
diff --git a/bin/straw-viewer b/bin/straw-viewer
index 147e16e..9ee0dea 100755
--- a/bin/straw-viewer
+++ b/bin/straw-viewer
@@ -211,11 +211,11 @@ my %CONFIG = (
# Subtitle options
srt_languages => ['en', 'es'],
- captions_dir => tmpdir(),
get_captions => 1,
auto_captions => 0,
copy_caption => 0,
- cache_dir => undef, # auto-defined
+ captions_dir => catdir(tmpdir(), 'straw-viewer'),
+ cache_dir => catdir(tmpdir(), 'straw-viewer'),
# API
api_host => "https://invidio.us",
@@ -552,12 +552,12 @@ sub load_config {
dump_configuration($config_file) if $update_config;
- # Create the cache directory (if needed)
- if (not -d $CONFIG{cache_dir}) {
- require File::Path;
- File::Path::make_path($CONFIG{cache_dir})
- or warn "[!] Can't create dir `$CONFIG{cache_dir}': $!";
- }
+foreach my $path($CONFIG{cache_dir}, $CONFIG{captions_dir}) {
+ next if -d $path;
+ require File::Path;
+ File::Path::make_path($path)
+ or warn "[!] Can't create path <<$path>>: $!";
+}
@opt{keys %CONFIG} = values(%CONFIG);
}
diff --git a/lib/WWW/StrawViewer.pm b/lib/WWW/StrawViewer.pm
index 097d218..38fa317 100644
--- a/lib/WWW/StrawViewer.pm
+++ b/lib/WWW/StrawViewer.pm
@@ -284,8 +284,7 @@ sub set_lwp_useragent {
my ($response) = @_;
my $code = $response->code;
- $code >= 500 # do not cache any bad response
- or $code == 401 # don't cache an unauthorized response
+ $code >= 400 # do not cache any bad response
or $response->request->method ne 'GET' # cache only GET requests
# don't cache if "cache-control" specifies "max-age=0" or "no-store"
diff --git a/lib/WWW/StrawViewer/Channels.pm b/lib/WWW/StrawViewer/Channels.pm
index 309aa07..b2c2c99 100644
--- a/lib/WWW/StrawViewer/Channels.pm
+++ b/lib/WWW/StrawViewer/Channels.pm
@@ -28,6 +28,11 @@ sub videos_from_channel_id {
return $self->_get_results($self->_make_feed_url("channels/$channel_id/videos"));
}
+sub videos_from_username {
+ my ($self, $channel_id) = @_;
+ return $self->_get_results($self->_make_feed_url("channels/$channel_id/videos"));
+}
+
=head2 channels_from_categoryID($category_id)
Return the YouTube channels associated with the specified category.