App-bookmarks

 view release on metacpan or  search on metacpan

script/bookmarks  view on Meta::CPAN

#!/usr/bin/env perl
#
# bookmarks - Export bookmarks from browsers and files
#
# Documentation at bottom of script.
#
# Implementation Notes :
#
# - For Safari, this tool relies on dirty plist parsing using Apple's 'plutil'
#   command. It should use Mac::PropertyList instead. For performance reasons
#   when used interactively, I've decided to keep it like that (see README.md).
# - Since Firefox sets an EXCLUSIVE SQLite lock, a tmp DB file copy is used.
# - sources are read as UTF-8.
#
# 2025.01.01 v0.35 jul : use 5.014
#                        fixed exit status
#                        added CSV and HTML output format
# 2024.03.09 v0.34 jul : added support for netscape
# 2022.12.22 v0.33 jul : fixed utf8 in stdout and firefox
#                        fixed bug in POD (wrong repo URL)
#                        doc arg "-" stdin as txt
# 2022.01.10 v0.32 jul : fixed bug in txt files regex (space)
#                        fixed bug with option -a (files not existing silently dropped)
#                        added support for arg '-' (read from STDIN as plain text file)
# 2021.03.30 v0.31 jul : skip gemini.t if URI::Find not installed
# 2021.03.29 v0.30 jul : added great markdown regex by Michaël Perrin
#                        process files without extension as plain text
#                        fixed extra spaces printed after empty fields
#                        added gemini support
# 2021.02.17 v0.28 jul : fixed missing require DBD::SQLite (firefox)
# 2021.02.16 v0.27 jul : added win32 Edge support, fixed Chrome bug (localappdata), fixed win32 bug (find), more tests (firefox)
# 2021.01.31 v0.26 jul : improved handling of optional dependencies
# 2021.01.31 v0.25 jul : skip bookmarks.t if URI::Find not installed
# 2021.01.31 v0.24 jul : fixed missing prereq URI::Find in Makefile.PL
# 2021.01.23 v0.23 jul : added tests and fixed firefox default location
# 2021.01.20 v0.22 jul : fixed firefox query again
# 2020.06.29 v0.21 jul : added markdown and text files support
# 2020.03.10 v0.20 jul : fixed EXCLUSIVE SQLite lock set by Firefox
# 2019.12.22 v0.19 jul : added chrome support, require, bugfixes
# 2019.10.22 v0.17 jul : created module
# 2019.10.17 v0.16 jul : fixed firefox tags
# 2019.09.27 v0.15 jul : added internet explorer support, fixed firefox tags
# 2019.08.13 v0.14 jul : added firefox support, output format
# 2019.07.11 v0.13 jul : use 5.010, better doc
# 2019.01.14 v0.12 jul : fixed case sensitive regex
# 2018.09.21 v0.11 jul : added arg and -a
# 2018.09.01 v0.10 jul : created

use 5.014;
use strict;
use warnings;
use utf8;
use Getopt::Std;
use File::Basename;
use File::Temp qw(tempdir);
use File::Copy qw(copy);
use open qw(:std :encoding(UTF-8));
use Encode qw(decode_utf8);

our $VERSION = '0.35';
my $program  = basename($0);
my $usage    = <<EOF;

Usage: $program [-hVdas] [-f format] [file ...]

    -h, --help      help
    -V, --version   version
    -d              debug (sent to STDERR)
    -a              all : process arguments and default locations
    -f format       export format : csv, csv-noheader, html, html-raw,
                    or any combination of characters t,u,d as
                    <title> <url> <description> (default : tud)
    -s              find schemeless URLs in text files (default : no)

See `perldoc $program` for full documentation.
EOF

# options

my %options = ();
getopts("hVdaf:s", \%options) or die $usage;

my $help        = $options{h} // 0;
my $version     = $options{V} // 0;
my $debug       = $options{d} // 0;
my $all         = $options{a} // 0;
my $format      = $options{f} // "tud";
my $schemeless  = $options{s} // 0;

die $usage if $help;
die $VERSION . "\n" if $version;

# option -a
if (!@ARGV or $all)



( run in 2.662 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )