<?php
/*
* tweeper - a Twitter to RSS web scraper
- *
- * Copyright (C) 2013 Antonio Ospite <ospite@studenti.unina.it>
- *
+ *
+ * Copyright (C) 2013-2014 Antonio Ospite <ao2@ao2.it>
+ *
* This program 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
* (at your option) any later version.
- *
+ *
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
"audio/aac",
"audio/mp4",
"audio/mpeg",
+ "audio/ogg",
"audio/vorbis",
"audio/wav",
"audio/webm",
echo usage($argv);
exit(0);
default:
- die(usage($argv));
+ fwrite(STDERR, usage($argv));
+ exit(1);
}
}
}
-if (php_sapi_name() != 'cli')
+if (php_sapi_name() != 'cli') {
$options = parse_options_query_string();
-else
+ $ERROR_STREAM = fopen('php://output', 'w');
+} else {
$options = parse_options_cli($argv, $argc);
+ $ERROR_STREAM = fopen('php://stderr', 'w');
+}
-if (!isset($options['src_url']))
- die(usage($argv));
+if (!isset($options['src_url'])) {
+ fwrite($ERROR_STREAM, usage($argv));
+ exit(1);
+}
$url = parse_url($options['src_url']);
-if (FALSE === $url || empty($url["host"]))
- die("Invalid url: ${options['src_url']}\n");
+if (FALSE === $url || empty($url["host"])) {
+ fwrite($ERROR_STREAM, "Invalid url: ${options['src_url']}\n");
+ exit(1);
+}
$stylesheet = "file://" . __DIR__ . "/rss_converter_" . $url["host"] . ".xsl";
-if (FALSE === file_exists($stylesheet))
- die("Conversion to RSS not supported: {$url["host"]}\n");
+if (FALSE === file_exists($stylesheet)) {
+ fwrite($ERROR_STREAM, "Conversion to RSS not supported: {$url["host"]}\n");
+ exit(1);
+}
$tweeper = new Tweeper($stylesheet, $options['generate_enclosure']);
echo $tweeper->tweep($options['src_url']);