#!/usr/bin/perl -w # # # rhautoimport # # Copyright (C) 2009-2017 Christian Pointner # # This file is part of rhautoimport. # # rhautoimport is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # any later version. # # rhautoimport is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with rhautoimport. If not, see . # use strict; use Date::Calc; use URI::URL; use HTML::Entities; use lib '../../rhrdlibs/lib/'; use lib '../'; use rhautoimport; use Data::Dumper::Simple; if($#ARGV != 0) { print "Usage: audioboom-inspect \n"; exit 1; } my $API_URL = "https://api.audioboom.com/users/" . $ARGV[0] . "/audio_clips"; binmode(STDIN, ":utf8"); binmode(STDOUT, ":utf8"); binmode(STDERR, ":utf8"); my ($result, $data) = rhautoimport::fetch_parse_json_audioboom($API_URL); unless ($result) { print "Error fetching data: $data\n"; exit 1; } my @clips = @{$data->{'body'}{'audio_clips'}}; my $uri = ""; my $file = ""; my $sum_title = ""; my $sum_text = ""; my $i = 0; for my $clip (@clips) { $i++; $sum_title = decode_entities($clip->{title}); if (defined $clip->{description}) { $sum_text = decode_entities($clip->{description}); } else { $sum_text = ''; } my $orig_uri = $clip->{urls}{high_mp3}; next unless $orig_uri; my $duration = $clip->{duration}; $duration = 0 unless (defined $duration); my $size = $clip->{mp3_filesize}; $size = 0 unless (defined $size); my @tags = @{$clip->{tags}}; my $recorded = $clip->{recorded_at}; $recorded = '' unless (defined $recorded); my $uploaded = $clip->{uploaded_at}; $uploaded = '' unless (defined $uploaded); $uri = new URI::URL($orig_uri); my @path = $uri->path_components; $file = $path[-1]; print $clip->{title} . ":\n"; # print " Description: " . $sum_text . "\n"; print " Recorded: " . $recorded . "\n"; print " Uploaded: " . $uploaded . "\n"; print " Tags: " . join(", ", @tags) . "\n"; print " Files:\n 1: (audio/mpeg, " . $size . ") " . $file . "\n"; print "\n"; } exit 0;