Skip to content

Commit

Permalink
Always scan channels for new videos when loading subscription videos …
Browse files Browse the repository at this point in the history
…for the first time in a session.

Then scan channels again when the previous results are older than 10 minutes.
  • Loading branch information
trizen committed Mar 24, 2022
1 parent 253edc4 commit f8f171d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 6 additions & 2 deletions bin/gtk-youtube-viewer
Original file line number Diff line number Diff line change
Expand Up @@ -2823,13 +2823,17 @@ sub get_results_from_list {
sub get_subscription_video_results {

state $t0 = time;
state $d0 = $t0;

# Reuse the subscription file if it's less than 10 minutes old
if ((time - $t0 <= 600) and (-f $local_subscription_videos_file) and (-M _) < (-M $CONFIG{youtube_users_file})) {
if ( $t0 != $d0
and (time - $t0 <= 600)
and (-f $local_subscription_videos_file)
and (-M $local_subscription_videos_file) < (-M $CONFIG{youtube_users_file})) {
return get_results_from_list(ids => [reverse $yv_utils->read_lines_from_file($local_subscription_videos_file)]);
}

$t0 = time;
$t0 = time+1;

my @channels = $yv_utils->read_channels_from_file($CONFIG{youtube_users_file});
my @channel_ids = map { $_->[0] } @channels;
Expand Down
10 changes: 7 additions & 3 deletions bin/youtube-viewer
Original file line number Diff line number Diff line change
Expand Up @@ -3442,13 +3442,17 @@ sub print_saved_videos {
sub print_local_subscription_videos {

state $t0 = time;
state $d0 = $t0;

# Reuse the subscription file if it's less than 10 minutes old
if ((time - $t0 <= 600) and (-f $local_subscription_videos_file) and (-M _) < (-M $opt{youtube_users_file})) {
if ( $t0 != $d0
and (time - $t0 <= 600)
and (-f $local_subscription_videos_file)
and (-M $local_subscription_videos_file) < (-M $opt{youtube_users_file})) {
return print_local_playlist($local_subscription_videos_file);
}

$t0 = time;
$t0 = time+1;

my @channels = $yv_utils->read_channels_from_file($opt{youtube_users_file});
my @channel_ids = map { $_->[0] } @channels;
Expand Down Expand Up @@ -5365,7 +5369,7 @@ Ignore videos in AV1 format.
=head2 ignored_projections
An array of video projects to ignore.
An array of video projections to ignore.
For example, to prefer rectangular projections of 360° videos, use:
Expand Down

0 comments on commit f8f171d

Please sign in to comment.