App-WatchLater

 view release on metacpan or  search on metacpan

lib/App/WatchLater.pm  view on Meta::CPAN

package App::WatchLater;

use 5.016;
use strict;
use warnings;

use Carp;
use DBI;
use Getopt::Long qw(:config auto_help gnu_getopt);
use Pod::Usage;
use Try::Tiny;

use App::WatchLater::YouTube;
use App::WatchLater::Browser;

=head1 NAME

App::WatchLater - Manage your YouTube Watch Later videos

=head1 VERSION

Version 0.03

=cut

our $VERSION = '0.03';


=head1 SYNOPSIS

    exit App::WatchLater::main();

=head1 DESCRIPTION

Manages a Watch Later queue of YouTube videos, in case you're one of the kinds
of people whose Watch Later lists get too out of hand. Google has deprecated the
ability to access the B<WL> playlist via the YouTube Data API, which means we
have to go to a bit more effort.

An API key is required to access the YouTube Data API. Alternatively, requests
may be authorized by providing an OAuth2 access token.

=head1 SUBROUTINES/METHODS

=cut

sub _ensure_schema {
  my $dbh = shift;
  $dbh->do(<<'SQL') or die $dbh->errstr;
CREATE TABLE IF NOT EXISTS videos(
  video_id      TEXT PRIMARY KEY,
  video_title   TEXT,
  channel_id    TEXT,
  channel_title TEXT,
  watched       INTEGER NOT NULL DEFAULT 0
);
SQL
}

sub _add {
  my ($dbh, $api, $opts, @video_ids) = @_;

  my $on_conflict = $opts->{force} ? 'REPLACE' : 'IGNORE';

  my $sth = $dbh->prepare_cached(<<SQL);
INSERT OR $on_conflict INTO videos
(video_id, video_title, channel_id, channel_title, watched)
VALUES (?, ?, ?, ?, 0);
SQL

  for my $vid (@video_ids) {



( run in 1.367 second using v1.01-cache-2.11-cpan-39bf76dae61 )