stable script

This commit is contained in:
h264 2024-05-26 01:40:13 -04:00
commit 65fde136f9
3 changed files with 61 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
tracklist.txt

51
DDtracklist.pl Normal file
View File

@ -0,0 +1,51 @@
#!/usr/bin/perl
use strict;
use warnings;
use HTML::TableExtract;
use LWP::Simple;
use feature "unicode_strings";
use open ':std', ':encoding(UTF-8)';
my $content;
my $url;
binmode STDOUT, ":utf8";
print "Enter a webpage to extract:\n";
$url = <STDIN>;
$content = get( $url );
die "Couldn't get URL" unless defined $content;
open( my $fh, ">:utf8", 'tracklist.txt');
my $te = HTML::TableExtract->new();
$te->parse( $content );
foreach my $ts ( $te->tables() )
{
foreach my $row ( $ts->rows() )
{
my $count = 0;
foreach my $element ( @$row )
{
$element =~ s/^\s+|\s+$//g; #remove all whitespace
if ($count == 1)
{
print "$element/";
print $fh "$element/";
}
if ($count == 2)
{
print "$element";
print $fh "$element";
}
$count++;
}
print "\n";
print $fh "\n";
}
}
close $fh;

9
README.md Normal file
View File

@ -0,0 +1,9 @@
A script for pulling the tracklist of albums I purchase from diverse.direct.
Run the script using the perl interpreter and enter the full url to the page of the CD you wish you dump the tracklist info.
The output is dumped into the tracklist file.
The file is overwritten on each run.
I added some text here to test something...