Rtmgr/Gen.pm untested

filter: Statementstmt 0.0% 0 / 51 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 74 CC 1 SCAR 6.9
CC
1
Cov
0%
run_print_config
2.0
run_create_db
2.0
run_db_pop_id
2.0
CRAP 2.0
1 package Rtmgr::Gen;
2  
3 use 5.006;
4 use strict;
5 use warnings;
6 use Data::Dump qw(dump);
7 use Config::File;
8  
9 our @ISA= qw( Exporter );
10  
11 use Rtmgr::Gen::Db qw(get_download_list create_db_table get_name get_tracker calc_scene insert_into_database_missing get_difference_between_server_and_database add_remove_extraneous_reccords);
12 use Exporter 'import';
13 our @EXPORT_OK = qw(get_download_list create_db_table get_name get_tracker calc_scene insert_into_database_missing get_difference_between_server_and_database add_remove_extraneous_reccords);
14  
15 our @EXPORT = qw( run_create_db run_db_pop_id run_extraneous_reccords run_db_pop_torname run_db_pop_tracker run_db_pop_srrdb );
16  
17
18 =head1 NAME
19  
20 Rtmgr::Gen - Connect to rTorrent/ruTorrent installation and get a list of torrents, storing them to a database.!
21  
22 =head1 VERSION
23  
24 Version 0.05
25  
26 =cut
27  
28 our $VERSION = '0.05';
29  
30  
31 =head1 SYNOPSIS
32  
33 Connects to a rTorrent/ruTorrent installation.
34  
35 =head1 SUBROUTINES/METHODS
36  
37 #use Rtmgr::Gen qw( run_create_db run_db_pop_id run_extraneous_reccords run_db_pop_torname run_db_pop_tracker run_db_pop_srrdb );
38  
39 ---
40 Create a config file called '.config' in the directory you will be running the module from.
41  
42 --- Content of .config file. ---
43  
44 SEEDBOX_UN = username
45 SEEDBOX_PW = password
46 SEEDBOX_HN = host
47 SEEDBOX_PR = 443
48 SEEDBOX_EP = RPC2
49 DATABASE = database
50 SRRDB_UN = srrdb_username
51 SRRDB_PW = srrdb_password
52  
53 --- ---
54  
55 #/usr/bin/env perl
56  
57 use Rtmgr::Gen;
58  
59 # Create the database.
60 Rtmgr::Gen->run_create_db();
61  
62 # Populate the database with torrent hashes.
63 Rtmgr::Gen->run_db_pop_id();
64  
65 # Remove Extraneous Reccords from Database.
66 Rtmgr::Gen->run_extraneous_reccords();
67  
68 # Populate the database with the names of the torrents.
69 Rtmgr::Gen->run_db_pop_torname();
70  
71 # Populate the database with the trackers.
72 Rtmgr::Gen->run_db_pop_tracker();
73  
74 # Populate the database with SRRDB Entry if available.
75 Rtmgr::Gen->run_db_pop_srrdb();
76  
77 =head2 get
78  
79 =cut
80  
81 # Config file setup.
82 my $configuration_file = '.config';
83 # Check for existence of config file.
84 if (not -e $configuration_file) {
85 print "The '.config' file does not exist!\n";
86 exit;
87 }
88 my $cnf = Config::File::read_config_file($configuration_file);
89  
90 sub run_print_config {
91 print "$cnf->{DATABASE}\n"; # Database
92 print "$cnf->{SEEDBOX_UN}\n"; # Username
93 print "$cnf->{SEEDBOX_PR}\n"; # Port
94 print "$cnf->{SEEDBOX_PW}\n"; # Password
95 print "$cnf->{SEEDBOX_HN}\n"; # Hostname
96 print "$cnf->{SEEDBOX_EP}\n"; # RPC2
97 print "$cnf->{SRRDB_PW}\n"; # SRRDB Password
98 print "$cnf->{SRRDB_UN}\n"; # SRRDB Username
99 }
100  
101 sub run_create_db {
102 # Create Database.
103 my $create_db = create_db_table("$cnf->{DATABASE}");
104 print $create_db;
105 }
106  
107 sub run_db_pop_id {
108 # Populate database with ID's 'HASH' of torrents.
109 my $dl_list_arr_ref = get_download_list("$cnf->{SEEDBOX_UN}","$cnf->{SEEDBOX_PW}","$cnf->{SEEDBOX_HN}","$cnf->{SEEDBOX_PR}","$cnf->{SEEDBOX_EP}","$cnf->{DATABASE}");
110 insert_into_database_missing($dl_list_arr_ref,"$cnf->{DATABASE}");
111 }
112  
113 sub run_extraneous_reccords {
114 # Remove Extraneous Reccords from Database.
115 my $dl_list_ext_reccords = get_download_list("$cnf->{SEEDBOX_UN}","$cnf->{SEEDBOX_PW}","$cnf->{SEEDBOX_HN}","$cnf->{SEEDBOX_PR}","$cnf->{SEEDBOX_EP}","$cnf->{DATABASE}");
116 my $diff_list = get_difference_between_server_and_database($dl_list_ext_reccords,"$cnf->{DATABASE}");
117 add_remove_extraneous_reccords($diff_list,'database');
118 }
119 sub run_db_pop_torname {
120 # Populate database with Torrent Names.
121 my $get_name = get_name("$cnf->{SEEDBOX_UN}","$cnf->{SEEDBOX_PW}","$cnf->{SEEDBOX_HN}","$cnf->{SEEDBOX_PR}","$cnf->{SEEDBOX_EP}","$cnf->{DATABASE}");
122 print $get_name;
123 }
124  
125 sub run_db_pop_tracker {
126 # Populate database with trackers.
127 my $get_tracker = get_tracker("$cnf->{SEEDBOX_UN}","$cnf->{SEEDBOX_PW}","$cnf->{SEEDBOX_HN}","$cnf->{SEEDBOX_PR}","$cnf->{SEEDBOX_EP}","$cnf->{DATABASE}");
128 print $get_tracker;
129 }
130  
131 sub run_db_pop_srrdb {
132 # Check if release is a scene release by checking for entry in srrdb.
133 my $calc_scene = calc_scene("$cnf->{SRRDB_UN}","$cnf->{SRRDB_PW}","$cnf->{DATABASE}");
134 print $calc_scene;
135 }
136  
137 =head1 AUTHOR
138  
139 Clem Morton, C<< <clem at cpan.org> >>
140  
141 =head1 BUGS
142  
143 Please report any bugs or feature requests to C<bug-rtmgr-gen-db at rt.cpan.org>, or through
144 the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Rtmgr-Gen-Db>. I will be notified, and then you'll
145 automatically be notified of progress on your bug as I make changes.
146  
147 =head1 SUPPORT
148  
149 You can find documentation for this module with the perldoc command.
150  
151 perldoc Rtmgr::Gen
152  
153 You can also look for information at:
154  
155 =over 4
156  
157 =item * RT: CPAN's request tracker (report bugs here)
158  
159 L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Rtmgr-Gen>
160  
161 =item * AnnoCPAN: Annotated CPAN documentation
162  
163 L<http://annocpan.org/dist/Rtmgr-Gen>
164  
165 =item * CPAN Ratings
166  
167 L<https://cpanratings.perl.org/d/Rtmgr-Gen>
168  
169 =item * Search CPAN
170  
171 L<https://metacpan.org/release/Rtmgr-Gen>
172  
173 =back
174  
175  
176 =head1 ACKNOWLEDGEMENTS
177  
178  
179 =head1 LICENSE AND COPYRIGHT
180  
181 This software is Copyright (c) 2020 by Clem Morton.
182  
183 This is free software, licensed under:
184  
185 The Artistic License 2.0 (GPL Compatible)
186  
187 =cut
188  
189 1; # End of Rtmgr::Gen