-
Notifications
You must be signed in to change notification settings - Fork 0
/
HomeLoadTV-cron.php
64 lines (50 loc) · 1.49 KB
/
HomeLoadTV-cron.php
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
#!/usr/bin/env php5
<?php
/**
* Example executable for cronjobs.
*
* @package HomeLoadTV
* @name Executable
* @description Executable for class HomeLoadTV.
* @author Rene Bartsch <rene@bartschnet.de>
* @copyright Rene Bartsch 2013
* @license GNU GPL v.3
* @link https://github.com/renneb/HLTVDLM
* @version $Id$
*/
// Exception handling
try {
// Include configuration and Homeload class
require_once('config.php');
require_once('HomeLoadTV.php');
// Create new HomeLoadTV object
$hltv = new HomeLoadTV($email, $password);
// Run HomeLoadTV request/download
$result = $hltv->download($directory, $happyhour, $limit, $emailFrom, $thumbnails, $verbose);
// Destroy HomeLoadTV object
unset($hltv);
// Display success message
if (verbose) {
echo "\t\t\tOK!\n";
}
// Exit with result of download method
exit($result);
} catch (Exception $e) {
// Create error message of exception
$err_msg = date('Y-m-d H:i:s ') . $e->getMessage();
// Write exception to log-file
error_log($err_msg . "\n", 3, $directory . '/HomeLoadTV.log');
// Send email with exception message
if(!empty($emailFrom)) {
mail($email, 'HomeLoadTV error message', $err_msg, 'From: ' . $emailFrom);
}
// Display exceptions in verbose mode
if ($verbose) {
echo "\t\t\t!!! Caught exception: ", $e->getMessage(), "\n";
}
// Exit with error return value.
if(0 === $e->getCode()) {
exit(99);
}
}
?>