-
Notifications
You must be signed in to change notification settings - Fork 15
/
dlSiteRename
executable file
·76 lines (61 loc) · 2.04 KB
/
dlSiteRename
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#! /usr/bin/perl
use 5.014;
use autodie;
#use LWP::Simple;
use Web::Query;
use JSON;
use Encode;
use Data::Dumper;
use DBI;
use DJVoiceConfig;
use open ":encoding(utf8)";
binmode(STDIN, ':encoding(utf8)');
binmode(STDOUT, ':encoding(utf8)');
binmode(STDERR, ':encoding(utf8)');
if(! ($ARGV[0] =~ /(RJ[0-9]{6})/) ){
die 'need RJ###### in $ARGV[0]';
}
my $target = $1;
my $driver = "SQLite";
my $database = $DJVoiceConfig::PUSH_DATABASE_PATH;
my $dsn = "DBI:$driver:dbname=$database";
my $userid = "";
my $password = "";
my $dbh = DBI->connect($dsn, $userid, $password, { RaiseError => 1 })
or die $DBI::errstr;
# print "Opened database successfully\n";
my $stmt = "SELECT COUNT(id), id, title, circle_name, date FROM voiceWork WHERE id = '$target';";
my $sth = $dbh->prepare( $stmt );
my $rv = $sth->execute() or die $DBI::errstr;
if($rv < 0){
print $DBI::errstr;
}
my @row = $sth->fetchrow_array();
my $param;
if($row[0]) {
$param->{'id' } = decode('UTF-8', $row[1]);
$param->{'title' } = decode('UTF-8', $row[2]);
$param->{'circle_name' } = decode('UTF-8', $row[3]);
$param->{'date' } = decode('UTF-8', $row[4]);
$param->{'genre' } = decode('UTF-8', '同人音声');
}else{
my $working_dir = $DJVoiceConfig::WORKING_DIR;
#my $target = 'RJ128196';
my $json_text = `$working_dir/grapDLSite $target`;
my $json_utf8 = encode('UTF-8', $json_text);
$param = decode_json($json_utf8);
}
my $id = $param->{'id' };
my $title = $param->{'title' };
my $circle_id = $param->{'circle_id' };
my $circle_name = $param->{'circle_name' };
my $image = $param->{'image' };
my $date = $param->{'date' };
my $tag = $param->{'tag' };
my $vocal = $param->{'vocal' };
my $genre = $param->{'genre' };
$date =~ s/-//g;
my $name = "[$date] [$circle_name] $title $id";
$name =~ s/\//@/g;
if($genre ne ''){ $name = "($genre) " . $name ; };
print $name;