Projects
Multimedia
cclive
Sign Up
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 2
View file
cclive.changes
Changed
@@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Sun Mar 13 12:55:01 UTC 2011 - pascal.bleser@opensuse.org + +- update to 0.7.3 (no user-visible changes) + +------------------------------------------------------------------- Sat Feb 12 23:46:36 UTC 2011 - pascal.bleser@opensuse.org - update to 0.7.2:
View file
cclive.spec
Changed
@@ -1,22 +1,21 @@ # vim: set ts=4 sw=4 et: Name: cclive -Version: 0.7.2 +Version: 0.7.3 Release: 1 Summary: Command Line Video Extraction Utility Source: http://prdownloads.sourceforge.net/cclive/cclive-%{version}.tar.gz -Patch3: cclive-cmake_backport.patch URL: http://cclive.sourceforge.net/ Group: Productivity/Networking/Other License: GNU General Public License version 3 (GPL v3) BuildRoot: %{_tmppath}/build-%{name}-%{version} %if %suse_version >= 1030 -BuildRequires: libcurl-devel +BuildRequires: libcurl-devel >= 7.20 %else -BuildRequires: curl-devel +BuildRequires: curl-devel >= 7.20 %endif BuildRequires: boost-devel -BuildRequires: pcre-devel +BuildRequires: pcre-devel >= 8.02 BuildRequires: libquvi-devel >= 0.2.0 Requires: libquvi0 >= 0.2.0 BuildRequires: gcc-c++ make glibc-devel pkg-config autoconf automake libtool @@ -31,26 +30,16 @@ features but some compromises were made along the way to keep the prerequisites low. - - - -Authors: --------- - Toni Gundogdu <legatvs@gmail.com> - - %prep %setup -q -%patch3 %build mkdir build pushd build +CFLAGS="%{optflags}" \ +CXXFLAGS="%{optflags}" \ cmake \ -DCMAKE_INSTALL_PREFIX="%{_prefix}" \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \ - -DCMAKE_C_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \ -DCMAKE_SKIP_RPATH=TRUE \ -DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE \ -DCMAKE_VERBOSE_MAKEFILE=TRUE \
View file
cclive-cmake_backport.patch
Deleted
@@ -1,30 +0,0 @@ ---- CMakeLists.txt.orig 2011-01-20 09:21:57.000000000 +0100 -+++ CMakeLists.txt 2011-01-20 09:27:02.000000000 +0100 -@@ -76,7 +76,7 @@ - - include (FindPkgConfig) - --pkg_check_modules (quvi libquvi>=0.2.0 REQUIRED QUIET) -+pkg_check_modules (quvi libquvi>=0.2.0 REQUIRED) - include_directories (AFTER ${quvi_INCLUDE_DIRS}) - link_directories (${quvi_LIBRARY_DIRS}) - -@@ -84,15 +84,15 @@ - set (HAVE_QUVIOPT_NOSHORTENED true) - endif () - --pkg_check_modules (curl libcurl>=7.20 REQUIRED QUIET) -+pkg_check_modules (curl libcurl>=7.20 REQUIRED) - include_directories (AFTER ${curl_INCLUDE_DIRS}) - link_directories (${curl_LIBRARY_DIRS}) - --pkg_check_modules (pcre libpcre>=8.02 REQUIRED QUIET) -+pkg_check_modules (pcre libpcre REQUIRED) - include_directories (AFTER ${pcre_INCLUDE_DIRS}) - link_directories (${pcre_LIBRARY_DIRS}) - --pkg_check_modules (pcrecpp libpcrecpp>=8.02 REQUIRED QUIET) -+pkg_check_modules (pcrecpp libpcrecpp REQUIRED) - include_directories (AFTER ${pcrecpp_INCLUDE_DIRS}) - link_directories (${pcrecpp_LIBRARY_DIRS}) -
View file
cclive-0.7.2.tar.gz/cclive
Deleted
-(directory)
View file
cclive-0.7.2.tar.gz/cclive/CMakeLists.txt
Deleted
@@ -1,40 +0,0 @@ - -set (cclive_SRC - src/application.cpp - src/background.cpp - src/error.cpp - src/exec.cpp - src/file.cpp - src/get.cpp - src/license.cpp - src/log.cpp - src/main.cpp - src/options.cpp - src/progressbar.cpp - src/re.cpp - src/wait.cpp -) - -add_executable (cclive ${cclive_SRC}) - -add_dependencies (cclive quvicpp) - -include_directories( - BEFORE - ${CMAKE_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${quvicpp_SOURCE_DIR}/include -) - -target_link_libraries (cclive - quvicpp # See lib/quvicpp/CMakeLists.txt - ${curl_LIBRARIES} - ${pcrecpp_LIBRARIES} - ${Boost_LIBRARIES} -) - -# Install. - -install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/cclive DESTINATION bin) - -
View file
cclive-0.7.2.tar.gz/cclive/include
Deleted
-(directory)
View file
cclive-0.7.2.tar.gz/cclive/include/cclive
Deleted
-(directory)
View file
cclive-0.7.2.tar.gz/cclive/src
Deleted
-(directory)
View file
cclive-0.7.2.tar.gz/cclive/src/file.cpp
Deleted
@@ -1,485 +0,0 @@ -/* -* Copyright (C) 2010 Toni Gundogdu <legatvs@gmail.com> -* -* 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/>. -*/ - -#include "config.h" - -#include <fstream> -#include <stdexcept> -#include <sstream> -#include <iomanip> - -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif - -#ifdef HAVE_SIGNAL_H -#include <signal.h> -#endif - -#if defined (HAVE_SIGNAL_H) && defined (HAVE_SIGNAL) -#define WITH_SIGNAL -#endif - -#include <boost/format.hpp> -#include <boost/foreach.hpp> -#include <boost/filesystem.hpp> - -#ifndef foreach -#define foreach BOOST_FOREACH -#endif - -#include <curl/curl.h> - -#include "quvicpp/quvicpp.h" - -#include "cclive/options.h" -#include "cclive/progressbar.h" -#include "cclive/re.h" -#include "cclive/error.h" -#include "cclive/log.h" -#include "cclive/file.h" - -namespace cclive -{ - -file::file () - : _initial_length(0) -{ } - -file::file ( - const quvicpp::video& video, - const quvicpp::link& link, - const int n, - const options& opts) - : _initial_length(0) -{ - _init (video, link, n, opts); -} - -file::file (const file& f) - : _initial_length(0) -{ - _swap(f); -} - -file& -file::operator=(const file& f) -{ - if (this != &f) _swap(f); - return *this; -} - -void -file::_swap (const file& f) -{ - _name = f._name; - _path = f._path; - _initial_length = f._initial_length; -} - -#define E "server response code %ld, expected 200 or 206 (conn_code=%ld)" - -static std::string -format_unexpected_http_error (const long resp_code, const long conn_code) -{ - return (boost::format (E) % resp_code % conn_code).str (); -} - -#undef E - -#define E "%s (curl_code=%ld, resp_code=%ld, conn_code=%ld)" - -static std::string -format_error ( - const CURLcode curl_code, - const long resp_code, - const long conn_code) -{ - const std::string e = curl_easy_strerror (curl_code); - return (boost::format (E) % e % curl_code % resp_code % conn_code).str (); -} - -#undef E - -static size_t -write_cb (void *data, size_t size, size_t nmemb, void *ptr) -{ - std::ofstream *o = reinterpret_cast<std::ofstream*>(ptr); - const size_t rsize = size*nmemb; - o->write (static_cast<char*>(data), rsize); - o->flush (); - return rsize; -} - -#ifdef WITH_SIGNAL -static volatile sig_atomic_t recv_usr1; - -static void -handle_usr1 (int s) -{ - if (s == SIGUSR1) - recv_usr1 = 1; -} -#endif - -static int -progress_cb (void *ptr, double, double now, double, double) -{ -#ifdef WITH_SIGNAL - if (recv_usr1) - { - recv_usr1 = 0; - return 1; // Return a non-zero value to abort this transfer. - } -#endif - reinterpret_cast<progressbar*>(ptr)->update (now); - return 0; -} - -namespace po = boost::program_options; - -bool -file::write ( - const quvicpp::query& q, - const quvicpp::link& l, - const options& opts) const -{ - CURL *curl = q.curlHandle(); - - curl_easy_setopt (curl, CURLOPT_URL, l.url().c_str()); - curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, write_cb); - - const po::variables_map map = opts.map(); - std::ios_base::openmode mode = std::ofstream::binary; - - if ( map.count ("overwrite") ) - mode |= std::ofstream::trunc; - else - { - if ( _should_continue() ) - mode |= std::ofstream::app; - } - - std::ofstream out( _path.c_str(), mode ); - - if ( out.fail() ) - { - std::string s = _path + ": "; - - if (errno) - s += cclive::perror (); - else - s += "unknown file open error"; - - throw std::runtime_error (s); - } - - curl_easy_setopt (curl, CURLOPT_WRITEDATA, &out); - - curl_easy_setopt (curl, CURLOPT_ENCODING, "identity"); - curl_easy_setopt (curl, CURLOPT_HEADER, 0L); - - progressbar pb (*this, l, opts); - curl_easy_setopt (curl, CURLOPT_PROGRESSDATA, &pb); - curl_easy_setopt (curl, CURLOPT_NOPROGRESS, 0L); - curl_easy_setopt (curl, CURLOPT_PROGRESSFUNCTION, progress_cb);
View file
cclive-0.7.2.tar.gz/cclive/src/options.cpp
Deleted
@@ -1,266 +0,0 @@ -/* -* Copyright (C) 2010,2011 Toni Gundogdu <legatvs@gmail.com> -* -* 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/>. -*/ - -#include "config.h" - -#include <fstream> -#include <cstring> - -#include <boost/filesystem.hpp> -#include <boost/foreach.hpp> - -#ifndef foreach -#define foreach BOOST_FOREACH -#endif - -#include "cclive/re.h" -#include "cclive/options.h" - -namespace cclive -{ - -namespace opts = boost::program_options; -namespace fs = boost::filesystem; - -void -options::exec (int argc, char **argv) -{ - - // Path to ccliverc. - - fs::path config_path (fs::initial_path<fs::path> ()); - - const char *home = getenv ("HOME"); - - if (home && strlen (home) > 0) - config_path = fs::system_complete (fs::path (home)); - - config_path /= -#ifndef _WIN32 - std::string (".") + -#endif - std::string ("ccliverc"); - - // Construct options. - - opts::options_description generic; - - generic.add_options() - ("version", - "Print version and exit") - ("help", - "Print help and exit") - ("license", - "Print license and exit") - ("support", - "Print supported websites and exit") - ("verbose-libcurl", - "Turn on libcurl verbose output") - ("quiet,q", - "Turn off all output, excl. errors") -#ifdef HAVE_FORK - ("background,b", - "Go to background") -#endif - ("format,f", - opts::value<std::string>()->default_value("default"), - "Download video format") - ("continue,c", - "Resume partially downloaded video") - ("overwrite,W", - "Overwrite existing video") - ("output-file,O", - opts::value<std::string>(), - "Write downloaded video to file") - ("no-download,n", - "Do not download video, print info only") -#ifdef HAVE_QUVIOPT_NOSHORTENED - ("no-shortened,s", - "Do not decompress shortened URLs") -#endif - ("no-proxy", - "Disable use of http proxy") - ("log-file", - opts::value<std::string>()->default_value("cclive_log"), - "Write log output to arg") - ("update-interval", - opts::value<double>()->default_value(1.0), - "Update interval of progressbar") - ("config-file", - opts::value<std::string>(&_config_file) - ->default_value(config_path.string()), - "File to read cclive arguments from") - ; - - // Config. - - opts::options_description config ("Configuration"); - - config.add_options () - ("filename-format", - opts::value<std::string>()->default_value("%t.%s"), - "Output video filename format") - ("output-dir", - opts::value<std::string>(), - "Output directory for downloaded videos") - ("regexp", - opts::value<std::string>()->default_value("/(\\w|\\pL|\\s)/g"), - "Regexp to clean up video title") - ("subst", opts::value<std::string>(), - "Replace matched occurences in filename") - ("exec", opts::value<std::string>(), - "Invoke arg after download finishes") - ("agent", - opts::value<std::string>()->default_value("Mozilla/5.0"), - "Identify as arg to http servers") - ("proxy", opts::value<std::string>(), - "Use proxy for http connections") - ("throttle", opts::value<int>()->default_value(0), - "Limit download transfer rate to KB/s") - ("connect-timeout", opts::value<int>()->default_value(30), - "Seconds connecting allowed to take") - ("transfer-timeout", opts::value<int>()->default_value(0), - "Seconds transfer allowed to take") - ("dns-cache-timeout", opts::value<int>()->default_value(60), - "Seconds dns resolves kept in memory") - ("max-retries", opts::value<int>()->default_value(5), - "Max download attempts before giving up") - ("retry-wait", opts::value<int>()->default_value(5), - "Time to wait before retrying") - ; - - // Hidden. - - opts::options_description hidden; - - hidden.add_options () - ("url", opts::value< std::vector<std::string> >(), - "url") - ; - - // Visible. - - _visible.add (generic).add (config); - - // Command line options. - - opts::options_description cmdline_options; - - cmdline_options.add (generic).add (config).add (hidden); - - // Config file options. - - opts::options_description config_file_options; - - config_file_options.add (config); - - // Positional. - - opts::positional_options_description p; - p.add ("url", -1); - - // Parse. - - store(opts::command_line_parser (argc,argv) - .options (cmdline_options).positional (p).run (), _map); - - notify (_map); - - // Read config. - - std::ifstream ifs (_config_file.c_str ()); - - if (ifs) - { - store (parse_config_file (ifs, config_file_options), _map); - notify (_map); - } - - _verify (); -} - -const opts::variables_map& options::map () const -{ - return _map; -}
View file
cclive-0.7.2.tar.gz/cclive/src/progressbar.cpp
Deleted
@@ -1,412 +0,0 @@ -/* -* Copyright (C) 2010 Toni Gundogdu <legatvs@gmail.com> -* -* 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/>. -*/ - -#include "config.h" - -#include <iomanip> -#include <cstdio> -#include <ctime> - -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif - -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif - -#ifdef HAVE_SIGNAL_H -#include <signal.h> -#endif - -#ifdef HAVE_SYS_IOCTL_H -#include <sys/ioctl.h> -#endif - -#include <boost/filesystem.hpp> -#include <boost/date_time/posix_time/posix_time.hpp> - -#include "quvicpp/quvicpp.h" - -#include "cclive/options.h" -#include "cclive/file.h" -#include "cclive/log.h" -#include "cclive/progressbar.h" - -#if defined(SIGWINCH) && defined(TIOCGWINSZ) -#define WITH_RESIZE -#endif - -namespace cclive -{ -#ifdef WITH_RESIZE -static volatile sig_atomic_t recv_sigwinch; - -static void handle_sigwinch (int s) -{ - recv_sigwinch = 1; -} - -static size_t get_term_width () -{ - const int fd = fileno (stderr); - - winsize wsz; - - if (ioctl (fd, TIOCGWINSZ, &wsz) < 0) - return 0; - - return wsz.ws_col; -} -#endif // WITH_RESIZE - -namespace po = boost::program_options; - -progressbar::progressbar ( - const file& f, - const quvicpp::link& l, - const options& opts) - : _update_interval (.2), - _expected_bytes (l.length ()), - _initial_bytes (f.initial_length ()), - _time_started (0), - _last_update (0), - _term_width (0), - _dot_count (0), - _count (0), - _width (0), - _file (f), - _done (false), - _mode (normal) -{ - if (_initial_bytes > _expected_bytes) - _expected_bytes = _initial_bytes; - -#ifdef WITH_RESIZE - signal (SIGWINCH, handle_sigwinch); - - if (!_term_width || recv_sigwinch) - { - _term_width = get_term_width (); - - if (!_term_width) - _term_width = default_term_width; - } -#else - _term_width = default_term_width; -#endif - - _width = _term_width; - - time (&_time_started); - - const po::variables_map map = opts.map (); - - if (map.count ("background")) - _mode = dotline; - - _update_interval = map["update-interval"].as<double>(); -} - -static double to_mb (const double bytes) -{ - return bytes/(1024*1024); -} - -namespace pt = boost::posix_time; - -static std::string to_s (const int secs) -{ - pt::time_duration td = pt::seconds (secs); - return pt::to_simple_string (td); -} - -static std::string to_unit (double& rate) -{ - std::string units = "K/s"; - if (rate >= 1024.0*1024.0*1024.0) - { - rate /= 1024.0*1024.0*1024.0; - units = "G/s"; - } - else if (rate >= 1024.0*1024.0) - { - rate /= 1024.0*1024.0; - units = "M/s"; - } - else - rate /= 1024.0; - return units; -} - -namespace fs = boost::filesystem; - -void -progressbar::update (double now) -{ - time_t tnow; - - time (&tnow); - - const time_t elapsed = tnow - _time_started; - - bool force_update = false; - -#ifdef WITH_RESIZE - if (recv_sigwinch && _mode == normal) - { - const size_t old_term_width = _term_width; - - _term_width = get_term_width (); - - if (!_term_width) - _term_width = default_term_width; - - if (_term_width != old_term_width) - { - _width = _term_width; - force_update = true; - } - - recv_sigwinch = 0; - } -#endif // WITH_RESIZE - - if (!_done) - { - if ((elapsed - _last_update) < _update_interval - && !force_update) - { - return; - } - } - else - now = _expected_bytes; -
View file
cclive-0.7.2.tar.gz/lib
Deleted
-(directory)
View file
cclive-0.7.2.tar.gz/lib/CMakeLists.txt
Deleted
@@ -1,2 +0,0 @@ - -subdirs (quvicpp)
View file
cclive-0.7.2.tar.gz/lib/quvicpp
Deleted
-(directory)
View file
cclive-0.7.2.tar.gz/lib/quvicpp/CMakeLists.txt
Deleted
@@ -1,22 +0,0 @@ - - -project (quvicpp) - -set (quvicpp_SRC - src/error.cpp - src/link.cpp - src/misc.cpp - src/options.cpp - src/query.cpp - src/video.cpp -) - -add_library (quvicpp ${quvicpp_SRC}) - -include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) - -target_link_libraries (quvicpp ${quvi_LIBRARIES}) - -link_directories (${quvicpp_BINARY_DIR}/quvicpp) - -
View file
cclive-0.7.2.tar.gz/lib/quvicpp/include
Deleted
-(directory)
View file
cclive-0.7.2.tar.gz/lib/quvicpp/include/quvicpp
Deleted
-(directory)
View file
cclive-0.7.2.tar.gz/lib/quvicpp/src
Deleted
-(directory)
View file
cclive-0.7.2.tar.gz/lib/quvicpp/src/query.cpp
Deleted
@@ -1,158 +0,0 @@ -/* -* Copyright (C) 2010 Toni Gundogdu <legatvs@gmail.com> -* -* 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/>. -*/ - -#include "config.h" - -#include <cassert> - -#include <quvicpp/quvicpp.h> - -namespace quvicpp -{ - -// Constructor. - -query::query () - : _quvi(NULL), _curl(NULL) -{ - _init(); -} - -// Copy constructor. - -query::query (const query& q) - : _quvi(NULL), _curl(NULL) -{ - _init(); -} - -// Copy assignment operator. - -query& -query::operator=(const query& q) -{ - if (this != &q) - { - _close(); - _init(); - } - return *this; -} - -// Destructor. - -query::~query () -{ - _close(); -} - -// Init. - -void -query::_init () -{ - - const QUVIcode rc = quvi_init(&_quvi); - - if (rc != QUVI_OK) - throw error(_quvi,rc); - - assert (_quvi != NULL); - - quvi_getinfo(_quvi, QUVIINFO_CURL, &_curl); - assert (_curl != NULL); -} - -// Close. - -void -query::_close () -{ - if (_quvi) - quvi_close (&_quvi); // Resets to NULL. - assert (_quvi == NULL); - _curl = NULL; -} - -// Parse. - -video -query::parse (const url& pageURL, const options& opts) const -{ - - // Friend of quvicpp::options class -> clean API. - - if (!opts._format.empty()) - quvi_setopt(_quvi, QUVIOPT_FORMAT, opts._format.c_str()); - - quvi_setopt(_quvi, QUVIOPT_STATUSFUNCTION, opts._statusfunc); - quvi_setopt(_quvi, QUVIOPT_WRITEFUNCTION, opts._writefunc); -#ifdef _0 - quvi_setopt(_quvi, QUVIOPT_NOVERIFY, opts._verify ? 1L:0L); -#endif -#ifdef HAVE_QUVIOPT_NOSHORTENED - quvi_setopt(_quvi, QUVIOPT_NOSHORTENED, opts._shortened ? 1L:0L); -#endif - - quvi_video_t qv; - - QUVIcode rc = - quvi_parse(_quvi, const_cast<char*>(pageURL.c_str()), &qv); - - if (rc != QUVI_OK) - throw error(_quvi,rc); - - assert (qv != NULL); - - video v(qv); - quvi_parse_close(&qv); - - return v; -} - -// Get. - -void* -query::curlHandle () const -{ - return _curl; -} - -// Support. - -std::map<std::string,std::string> -query::support () const -{ - - std::map<std::string,std::string> map; - char *d=NULL, *f=NULL; - - while (quvi_next_supported_website(_quvi, &d, &f) == QUVI_OK) - { - map[d] = f; - quvi_free(d); - d = NULL; - quvi_free(f); - f = NULL; - } - - return map; -} - -} // End namespace - -// vim: set ts=2 sw=2 tw=72 expandtab:
View file
cclive-0.7.2.tar.gz/CMakeLists.txt -> cclive-0.7.3.tar.gz/CMakeLists.txt
Changed
@@ -8,7 +8,7 @@ # Version. -set (VERSION "0.7.2") +set (VERSION "0.7.3") set (VERSION_LONG "${VERSION}") set (BRANCH "master") @@ -72,6 +72,10 @@ set (WITHOUT_DOC false) endif () +# Include dir. + +include_directories (BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/include) + # Prerequisites. include (FindPkgConfig) @@ -84,6 +88,10 @@ set (HAVE_QUVIOPT_NOSHORTENED true) endif () +if (quvi_VERSION VERSION_GREATER 0.2.11) + set (HAVE_QUVIOPT_CATEGORY true) +endif () + pkg_check_modules (curl libcurl>=7.20 REQUIRED QUIET) include_directories (AFTER ${curl_INCLUDE_DIRS}) link_directories (${curl_LIBRARY_DIRS}) @@ -121,6 +129,18 @@ set (boost_VERSION "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") +# Version 3 is a major revision with many new and improved features. It +# may, however, break some user code written for Version 2. +# +# To ease the transition, Boost releases 1.44 through 1.47 will supply +# both V2 and V3. Version 2 is the default version for Boost release 1.44 +# and 1.45. Version 3 will be the default starting with release 1.46. +# <http://www.boost.org/libs/filesystem/index.html> + +if (boost_VERSION VERSION_GREATER 1.43.0) + set (HAVE_BOOST_FILESYSTEM_VERSION_3 true) +endif () + # Check for headers. include (CheckIncludeFile) @@ -142,7 +162,7 @@ # Subdirs. -subdirs (lib cclive man1) +subdirs (src man1) # Status.
View file
cclive-0.7.2.tar.gz/ChangeLog -> cclive-0.7.3.tar.gz/ChangeLog
Changed
@@ -1,3 +1,168 @@ +commit b1d8a68abb7bb046c6b11bb94094fb70906cfa4d +Author: Toni Gundogdu <legatvs.git@gmail.com> +Date: Sat Mar 12 14:10:42 2011 +0200 + + Set release details for 0.7.3 + + NEWS | 12 ++++++++++++ + 1 files changed, 12 insertions(+), 0 deletions(-) + +commit c82db79c1dd44b621d35d17e6d43cd4cae6a9eac +Author: Toni Gundogdu <legatvs.git@gmail.com> +Date: Sat Mar 12 14:10:34 2011 +0200 + + Regenerate manual for 0.7.3 + + man1/cclive.1 | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +commit 77e82144cdf7a8a4e6fc296b746d14d273c4df68 +Author: Toni Gundogdu <legatvs.git@gmail.com> +Date: Sun Mar 6 12:57:22 2011 +0200 + + Fix compilation with Boost::Filesystem v3 (#6) + + Version 3 is the new default in boost::filesystem (as of 1.46.0). + This breaks the code written for boost::filesystem version 2. + + * Define BOOST_FILESYSTEM_NO_DEPRECATED + * Define BOOST_FILESYSTEM_VERSION as 3 (boost 1.44.0+) + * boost::filesystem::initial_path (depr.) -> *::*::current_path + * http://sourceforge.net/apps/trac/cclive/ticket/6 + + CMakeLists.txt | 12 ++++++++++++ + config.h.cmake.in | 16 +++++++++++++++- + src/cclive/file.cpp | 13 +++++++++++++ + src/cclive/options.cpp | 6 +++++- + src/cclive/progressbar.cpp | 6 +++++- + 5 files changed, 50 insertions(+), 3 deletions(-) + +commit b8dc4f92bf289fcd097fc40947ac89b9fedbfe6a +Author: Toni Gundogdu <legatvs.git@gmail.com> +Date: Sun Mar 6 12:13:40 2011 +0200 + + options.cpp: Remove extra newlines + + src/cclive/options.cpp | 7 ------- + 1 files changed, 0 insertions(+), 7 deletions(-) + +commit 6d581d57c4f88ed1b2ba25d2669c699df982eabc +Author: Toni Gundogdu <legatvs.git@gmail.com> +Date: Fri Feb 18 10:21:28 2011 +0200 + + Add HAVE_QUVIOPT_CATEGORY check + + Set QUVIPROTO_HTTP should libquvi default value ever change. + + CMakeLists.txt | 4 ++++ + config.h.cmake.in | 1 + + src/quvicpp/query.cpp | 3 +++ + 3 files changed, 8 insertions(+), 0 deletions(-) + +commit 3a867d7cd56c19f3191c3cbf58021c4b533660e1 +Author: Toni Gundogdu <legatvs.git@gmail.com> +Date: Thu Feb 17 12:27:58 2011 +0200 + + Do not build quvicpp as a (static) library + + quvicpp was originally intended to be a "convenience library". CMake + does not currently support such libraries. quvicpp was therefore built + as a static library instead. This, however, creates packaging issues + with some of the current distros that pose strict security rules. + + List quvicpp source files in the "cclive" target instead. Reshuffle dir + structure. + + [1] http://www.vtk.org/Wiki/CMake_FAQ#Does_CMake_support_.22convenience.22_libraries.3F + [x] http://www.gnu.org/software/hello/manual/automake/Libtool-Convenience-Libraries.html + + CMakeLists.txt | 6 +- + cclive/CMakeLists.txt | 40 --- + cclive/include/cclive/application.h | 46 --- + cclive/include/cclive/background.h | 31 -- + cclive/include/cclive/error.h | 30 -- + cclive/include/cclive/exec.h | 31 -- + cclive/include/cclive/file.h | 56 ---- + cclive/include/cclive/get.h | 33 --- + cclive/include/cclive/log.h | 87 ------ + cclive/include/cclive/options.h | 44 --- + cclive/include/cclive/progressbar.h | 74 ----- + cclive/include/cclive/re.h | 40 --- + cclive/include/cclive/wait.h | 31 -- + cclive/src/application.cpp | 469 ------------------------------- + cclive/src/background.cpp | 94 ------- + cclive/src/error.cpp | 51 ---- + cclive/src/exec.cpp | 69 ----- + cclive/src/file.cpp | 485 --------------------------------- + cclive/src/get.cpp | 95 ------- + cclive/src/license.cpp | 41 --- + cclive/src/log.cpp | 145 ---------- + cclive/src/main.cpp | 49 ---- + cclive/src/options.cpp | 266 ------------------ + cclive/src/progressbar.cpp | 414 ---------------------------- + cclive/src/re.cpp | 128 --------- + cclive/src/wait.cpp | 59 ---- + include/cclive/application.h | 46 +++ + include/cclive/background.h | 31 ++ + include/cclive/error.h | 30 ++ + include/cclive/exec.h | 31 ++ + include/cclive/file.h | 56 ++++ + include/cclive/get.h | 33 +++ + include/cclive/log.h | 87 ++++++ + include/cclive/options.h | 44 +++ + include/cclive/progressbar.h | 74 +++++ + include/cclive/re.h | 40 +++ + include/cclive/wait.h | 31 ++ + include/quvicpp/quvicpp.h | 179 ++++++++++++ + lib/CMakeLists.txt | 2 - + lib/quvicpp/CMakeLists.txt | 22 -- + lib/quvicpp/include/quvicpp/quvicpp.h | 179 ------------ + lib/quvicpp/src/error.cpp | 86 ------ + lib/quvicpp/src/link.cpp | 112 -------- + lib/quvicpp/src/misc.cpp | 53 ---- + lib/quvicpp/src/options.cpp | 101 ------- + lib/quvicpp/src/query.cpp | 158 ----------- + lib/quvicpp/src/video.cpp | 189 ------------- + src/CMakeLists.txt | 45 +++ + src/cclive/application.cpp | 469 +++++++++++++++++++++++++++++++ + src/cclive/background.cpp | 94 +++++++ + src/cclive/error.cpp | 51 ++++ + src/cclive/exec.cpp | 69 +++++ + src/cclive/file.cpp | 485 +++++++++++++++++++++++++++++++++ + src/cclive/get.cpp | 95 +++++++ + src/cclive/license.cpp | 41 +++ + src/cclive/log.cpp | 145 ++++++++++ + src/cclive/main.cpp | 49 ++++ + src/cclive/options.cpp | 266 ++++++++++++++++++ + src/cclive/progressbar.cpp | 414 ++++++++++++++++++++++++++++ + src/cclive/re.cpp | 128 +++++++++ + src/cclive/wait.cpp | 59 ++++ + src/quvicpp/error.cpp | 86 ++++++ + src/quvicpp/link.cpp | 112 ++++++++ + src/quvicpp/misc.cpp | 53 ++++ + src/quvicpp/options.cpp | 101 +++++++ + src/quvicpp/query.cpp | 158 +++++++++++ + src/quvicpp/video.cpp | 189 +++++++++++++ + 67 files changed, 3796 insertions(+), 3811 deletions(-) + +commit d10c2eb50badd1535da9c3d7a49a12d4ac5b099c +Author: Toni Gundogdu <legatvs.git@gmail.com> +Date: Thu Feb 17 11:48:58 2011 +0200 + + Progressbar: Add inactive flag + + cclive/src/progressbar.cpp | 4 +++- + 1 files changed, 3 insertions(+), 1 deletions(-) + +commit f077b2b4557ec68cd05713c0cf350578d2006a12 +Author: Toni Gundogdu <legatvs.git@gmail.com> +Date: Mon Feb 7 22:47:42 2011 +0200 + + Bump version to 0.7.3 + + CMakeLists.txt | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + commit 0eb2222be1a2e70ffb15db594050ad2c2f5b729f Author: Toni Gundogdu <legatvs.git@gmail.com> Date: Mon Feb 7 22:16:37 2011 +0200
View file
cclive-0.7.2.tar.gz/NEWS -> cclive-0.7.3.tar.gz/NEWS
Changed
@@ -1,4 +1,16 @@ +0.7.3 Sat Mar 12 2011 Toni Gundogdu +Changes: + - Add QUVIOPT_CATEGORY check + - Set QUVIPROTO_HTTP + - Do not build quvicpp as a static library + - Build quvicpp in the "cclive" target instead + - See also ChangeLog for 3a867d7 commit message +Bugfixes: + - Compilation with boost 1.46.0 (#6) + - Boost::Filesystem uses v3 as the new default in 1.46.0 + + 0.7.2 Mon Feb 07 2011 Toni Gundogdu Changes: - Add SIGUSR1 handler
View file
cclive-0.7.2.tar.gz/config.h.cmake.in -> cclive-0.7.3.tar.gz/config.h.cmake.in
Changed
@@ -5,6 +5,8 @@ #define VERSION "${VERSION}" #define VERSION_LONG "${VERSION_LONG}" +// System. + #cmakedefine HAVE_UNISTD_H #cmakedefine HAVE_SYS_TYPES_H #cmakedefine HAVE_SYS_IOCTL_H @@ -18,8 +20,21 @@ #cmakedefine HAVE_GETPID #cmakedefine HAVE_SIGNAL +// quvi. + #cmakedefine HAVE_QUVIOPT_NOSHORTENED +#cmakedefine HAVE_QUVIOPT_CATEGORY -#endif +// Boost. See also CMakeLists.txt for notes. + +#define BOOST_FILESYSTEM_NO_DEPRECATED +#cmakedefine HAVE_BOOST_FILESYSTEM_VERSION_3 // 1.44.0+ +#ifdef HAVE_BOOST_FILESYSTEM_VERSION_3 + #ifndef BOOST_FILESYSTEM_VERSION + #define BOOST_FILESYSTEM_VERSION 3 // Default in 1.46.0 + #endif +#endif + +#endif
View file
cclive-0.7.3.tar.gz/include
Added
+(directory)
View file
cclive-0.7.3.tar.gz/include/cclive
Added
+(directory)
View file
cclive-0.7.3.tar.gz/include/cclive/application.h
Changed
(renamed from cclive/include/cclive/application.h)
View file
cclive-0.7.3.tar.gz/include/cclive/background.h
Changed
(renamed from cclive/include/cclive/background.h)
View file
cclive-0.7.3.tar.gz/include/cclive/error.h
Changed
(renamed from cclive/include/cclive/error.h)
View file
cclive-0.7.3.tar.gz/include/cclive/exec.h
Changed
(renamed from cclive/include/cclive/exec.h)
View file
cclive-0.7.3.tar.gz/include/cclive/file.h
Changed
(renamed from cclive/include/cclive/file.h)
View file
cclive-0.7.3.tar.gz/include/cclive/get.h
Changed
(renamed from cclive/include/cclive/get.h)
View file
cclive-0.7.3.tar.gz/include/cclive/log.h
Changed
(renamed from cclive/include/cclive/log.h)
View file
cclive-0.7.3.tar.gz/include/cclive/options.h
Changed
(renamed from cclive/include/cclive/options.h)
View file
cclive-0.7.3.tar.gz/include/cclive/progressbar.h
Changed
(renamed from cclive/include/cclive/progressbar.h)
View file
cclive-0.7.3.tar.gz/include/cclive/re.h
Changed
(renamed from cclive/include/cclive/re.h)
View file
cclive-0.7.3.tar.gz/include/cclive/wait.h
Changed
(renamed from cclive/include/cclive/wait.h)
View file
cclive-0.7.3.tar.gz/include/quvicpp
Added
+(directory)
View file
cclive-0.7.3.tar.gz/include/quvicpp/quvicpp.h
Changed
(renamed from lib/quvicpp/include/quvicpp/quvicpp.h)
View file
cclive-0.7.2.tar.gz/man1/cclive.1 -> cclive-0.7.3.tar.gz/man1/cclive.1
Changed
@@ -124,7 +124,7 @@ .\" ======================================================================== .\" .IX Title "cclive 1" -.TH cclive 1 "2011-02-03" "0.7.2" "cclive manual" +.TH cclive 1 "2011-02-03" "0.7.3" "cclive manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l
View file
cclive-0.7.3.tar.gz/src
Added
+(directory)
View file
cclive-0.7.3.tar.gz/src/CMakeLists.txt
Added
@@ -0,0 +1,45 @@ + +set (cclive_SRC + cclive/application.cpp + cclive/background.cpp + cclive/error.cpp + cclive/exec.cpp + cclive/file.cpp + cclive/get.cpp + cclive/license.cpp + cclive/log.cpp + cclive/main.cpp + cclive/options.cpp + cclive/progressbar.cpp + cclive/re.cpp + cclive/wait.cpp +) + +set (quvicpp_SRC + quvicpp/error.cpp + quvicpp/link.cpp + quvicpp/misc.cpp + quvicpp/options.cpp + quvicpp/query.cpp + quvicpp/video.cpp +) + +add_executable (cclive ${quvicpp_SRC} ${cclive_SRC}) + +include_directories( + BEFORE + ${CMAKE_BINARY_DIR} +) + +target_link_libraries (cclive + ${quvi_LIBRARIES} + ${curl_LIBRARIES} + ${pcrecpp_LIBRARIES} + ${Boost_LIBRARIES} +) + +# Install. + +install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/cclive DESTINATION bin) + +
View file
cclive-0.7.3.tar.gz/src/cclive
Added
+(directory)
View file
cclive-0.7.3.tar.gz/src/cclive/application.cpp
Changed
(renamed from cclive/src/application.cpp)
View file
cclive-0.7.3.tar.gz/src/cclive/background.cpp
Changed
(renamed from cclive/src/background.cpp)
View file
cclive-0.7.3.tar.gz/src/cclive/error.cpp
Changed
(renamed from cclive/src/error.cpp)
View file
cclive-0.7.3.tar.gz/src/cclive/exec.cpp
Changed
(renamed from cclive/src/exec.cpp)
View file
cclive-0.7.3.tar.gz/src/cclive/file.cpp
Added
@@ -0,0 +1,498 @@ +/* +* Copyright (C) 2010 Toni Gundogdu <legatvs@gmail.com> +* +* 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/>. +*/ + +#include "config.h" + +#include <fstream> +#include <stdexcept> +#include <sstream> +#include <iomanip> + +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + +#ifdef HAVE_SIGNAL_H +#include <signal.h> +#endif + +#if defined (HAVE_SIGNAL_H) && defined (HAVE_SIGNAL) +#define WITH_SIGNAL +#endif + +#include <boost/format.hpp> +#include <boost/foreach.hpp> +#include <boost/filesystem.hpp> + +#ifndef foreach +#define foreach BOOST_FOREACH +#endif + +#include <curl/curl.h> + +#include "quvicpp/quvicpp.h" + +#include "cclive/options.h" +#include "cclive/progressbar.h" +#include "cclive/re.h" +#include "cclive/error.h" +#include "cclive/log.h" +#include "cclive/file.h" + +namespace cclive +{ + +file::file () + : _initial_length(0) +{ } + +file::file ( + const quvicpp::video& video, + const quvicpp::link& link, + const int n, + const options& opts) + : _initial_length(0) +{ + _init (video, link, n, opts); +} + +file::file (const file& f) + : _initial_length(0) +{ + _swap(f); +} + +file& +file::operator=(const file& f) +{ + if (this != &f) _swap(f); + return *this; +} + +void +file::_swap (const file& f) +{ + _name = f._name; + _path = f._path; + _initial_length = f._initial_length; +} + +#define E "server response code %ld, expected 200 or 206 (conn_code=%ld)" + +static std::string +format_unexpected_http_error (const long resp_code, const long conn_code) +{ + return (boost::format (E) % resp_code % conn_code).str (); +} + +#undef E + +#define E "%s (curl_code=%ld, resp_code=%ld, conn_code=%ld)" + +static std::string +format_error ( + const CURLcode curl_code, + const long resp_code, + const long conn_code) +{ + const std::string e = curl_easy_strerror (curl_code); + return (boost::format (E) % e % curl_code % resp_code % conn_code).str (); +} + +#undef E + +static size_t +write_cb (void *data, size_t size, size_t nmemb, void *ptr) +{ + std::ofstream *o = reinterpret_cast<std::ofstream*>(ptr); + const size_t rsize = size*nmemb; + o->write (static_cast<char*>(data), rsize); + o->flush (); + return rsize; +} + +#ifdef WITH_SIGNAL +static volatile sig_atomic_t recv_usr1; + +static void +handle_usr1 (int s) +{ + if (s == SIGUSR1) + recv_usr1 = 1; +} +#endif + +static int +progress_cb (void *ptr, double, double now, double, double) +{ +#ifdef WITH_SIGNAL + if (recv_usr1) + { + recv_usr1 = 0; + return 1; // Return a non-zero value to abort this transfer. + } +#endif + reinterpret_cast<progressbar*>(ptr)->update (now); + return 0; +} + +namespace po = boost::program_options; + +bool +file::write ( + const quvicpp::query& q, + const quvicpp::link& l, + const options& opts) const +{ + CURL *curl = q.curlHandle(); + + curl_easy_setopt (curl, CURLOPT_URL, l.url().c_str()); + curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, write_cb); + + const po::variables_map map = opts.map(); + std::ios_base::openmode mode = std::ofstream::binary; + + if ( map.count ("overwrite") ) + mode |= std::ofstream::trunc; + else + { + if ( _should_continue() ) + mode |= std::ofstream::app; + } + + std::ofstream out( _path.c_str(), mode ); + + if ( out.fail() ) + { + std::string s = _path + ": "; + + if (errno) + s += cclive::perror (); + else + s += "unknown file open error"; + + throw std::runtime_error (s); + } + + curl_easy_setopt (curl, CURLOPT_WRITEDATA, &out); + + curl_easy_setopt (curl, CURLOPT_ENCODING, "identity"); + curl_easy_setopt (curl, CURLOPT_HEADER, 0L); + + progressbar pb (*this, l, opts); + curl_easy_setopt (curl, CURLOPT_PROGRESSDATA, &pb); + curl_easy_setopt (curl, CURLOPT_NOPROGRESS, 0L); + curl_easy_setopt (curl, CURLOPT_PROGRESSFUNCTION, progress_cb);
View file
cclive-0.7.3.tar.gz/src/cclive/get.cpp
Changed
(renamed from cclive/src/get.cpp)
View file
cclive-0.7.3.tar.gz/src/cclive/license.cpp
Changed
(renamed from cclive/src/license.cpp)
View file
cclive-0.7.3.tar.gz/src/cclive/log.cpp
Changed
(renamed from cclive/src/log.cpp)
View file
cclive-0.7.3.tar.gz/src/cclive/main.cpp
Changed
(renamed from cclive/src/main.cpp)
View file
cclive-0.7.3.tar.gz/src/cclive/options.cpp
Added
@@ -0,0 +1,263 @@ +/* +* Copyright (C) 2010,2011 Toni Gundogdu <legatvs@gmail.com> +* +* 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/>. +*/ + +#include "config.h" + +#include <fstream> +#include <cstring> + +#include <boost/filesystem.hpp> +#include <boost/foreach.hpp> + +#ifndef foreach +#define foreach BOOST_FOREACH +#endif + +#include "cclive/re.h" +#include "cclive/options.h" + +namespace cclive +{ + +namespace opts = boost::program_options; +namespace fs = boost::filesystem; + +void +options::exec (int argc, char **argv) +{ + // Path to ccliverc. + +#ifdef HAVE_BOOST_FILESYSTEM_VERSION_3 + fs::path config_path(fs::current_path()); +#else + fs::path config_path(fs::current_path<fs::path>()); +#endif + + const char *home = getenv ("HOME"); + + if (home && strlen (home) > 0) + config_path = fs::system_complete (fs::path (home)); + + config_path /= +#ifndef _WIN32 + std::string (".") + +#endif + std::string ("ccliverc"); + + // Construct options. + + opts::options_description generic; + + generic.add_options() + ("version", + "Print version and exit") + ("help", + "Print help and exit") + ("license", + "Print license and exit") + ("support", + "Print supported websites and exit") + ("verbose-libcurl", + "Turn on libcurl verbose output") + ("quiet,q", + "Turn off all output, excl. errors") +#ifdef HAVE_FORK + ("background,b", + "Go to background") +#endif + ("format,f", + opts::value<std::string>()->default_value("default"), + "Download video format") + ("continue,c", + "Resume partially downloaded video") + ("overwrite,W", + "Overwrite existing video") + ("output-file,O", + opts::value<std::string>(), + "Write downloaded video to file") + ("no-download,n", + "Do not download video, print info only") +#ifdef HAVE_QUVIOPT_NOSHORTENED + ("no-shortened,s", + "Do not decompress shortened URLs") +#endif + ("no-proxy", + "Disable use of http proxy") + ("log-file", + opts::value<std::string>()->default_value("cclive_log"), + "Write log output to arg") + ("update-interval", + opts::value<double>()->default_value(1.0), + "Update interval of progressbar") + ("config-file", + opts::value<std::string>(&_config_file) + ->default_value(config_path.string()), + "File to read cclive arguments from") + ; + + // Config. + + opts::options_description config ("Configuration"); + + config.add_options () + ("filename-format", + opts::value<std::string>()->default_value("%t.%s"), + "Output video filename format") + ("output-dir", + opts::value<std::string>(), + "Output directory for downloaded videos") + ("regexp", + opts::value<std::string>()->default_value("/(\\w|\\pL|\\s)/g"), + "Regexp to clean up video title") + ("subst", opts::value<std::string>(), + "Replace matched occurences in filename") + ("exec", opts::value<std::string>(), + "Invoke arg after download finishes") + ("agent", + opts::value<std::string>()->default_value("Mozilla/5.0"), + "Identify as arg to http servers") + ("proxy", opts::value<std::string>(), + "Use proxy for http connections") + ("throttle", opts::value<int>()->default_value(0), + "Limit download transfer rate to KB/s") + ("connect-timeout", opts::value<int>()->default_value(30), + "Seconds connecting allowed to take") + ("transfer-timeout", opts::value<int>()->default_value(0), + "Seconds transfer allowed to take") + ("dns-cache-timeout", opts::value<int>()->default_value(60), + "Seconds dns resolves kept in memory") + ("max-retries", opts::value<int>()->default_value(5), + "Max download attempts before giving up") + ("retry-wait", opts::value<int>()->default_value(5), + "Time to wait before retrying") + ; + + // Hidden. + + opts::options_description hidden; + + hidden.add_options () + ("url", opts::value< std::vector<std::string> >(), + "url") + ; + + // Visible. + + _visible.add (generic).add (config); + + // Command line options. + + opts::options_description cmdline_options; + + cmdline_options.add (generic).add (config).add (hidden); + + // Config file options. + + opts::options_description config_file_options; + + config_file_options.add (config); + + // Positional. + + opts::positional_options_description p; + p.add ("url", -1); + + // Parse. + + store(opts::command_line_parser (argc,argv) + .options (cmdline_options).positional (p).run (), _map); + + notify (_map); + + // Read config. + + std::ifstream ifs (_config_file.c_str ()); + + if (ifs) + { + store (parse_config_file (ifs, config_file_options), _map); + notify (_map); + } + + _verify (); +} + +const opts::variables_map& options::map () const
View file
cclive-0.7.3.tar.gz/src/cclive/progressbar.cpp
Added
@@ -0,0 +1,418 @@ +/* +* Copyright (C) 2010 Toni Gundogdu <legatvs@gmail.com> +* +* 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/>. +*/ + +#include "config.h" + +#include <iomanip> +#include <cstdio> +#include <ctime> + +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif + +#ifdef HAVE_SIGNAL_H +#include <signal.h> +#endif + +#ifdef HAVE_SYS_IOCTL_H +#include <sys/ioctl.h> +#endif + +#include <boost/filesystem.hpp> +#include <boost/date_time/posix_time/posix_time.hpp> + +#include "quvicpp/quvicpp.h" + +#include "cclive/options.h" +#include "cclive/file.h" +#include "cclive/log.h" +#include "cclive/progressbar.h" + +#if defined(SIGWINCH) && defined(TIOCGWINSZ) +#define WITH_RESIZE +#endif + +namespace cclive +{ +#ifdef WITH_RESIZE +static volatile sig_atomic_t recv_sigwinch; + +static void handle_sigwinch (int s) +{ + recv_sigwinch = 1; +} + +static size_t get_term_width () +{ + const int fd = fileno (stderr); + + winsize wsz; + + if (ioctl (fd, TIOCGWINSZ, &wsz) < 0) + return 0; + + return wsz.ws_col; +} +#endif // WITH_RESIZE + +namespace po = boost::program_options; + +progressbar::progressbar ( + const file& f, + const quvicpp::link& l, + const options& opts) + : _update_interval (.2), + _expected_bytes (l.length ()), + _initial_bytes (f.initial_length ()), + _time_started (0), + _last_update (0), + _term_width (0), + _dot_count (0), + _count (0), + _width (0), + _file (f), + _done (false), + _mode (normal) +{ + if (_initial_bytes > _expected_bytes) + _expected_bytes = _initial_bytes; + +#ifdef WITH_RESIZE + signal (SIGWINCH, handle_sigwinch); + + if (!_term_width || recv_sigwinch) + { + _term_width = get_term_width (); + + if (!_term_width) + _term_width = default_term_width; + } +#else + _term_width = default_term_width; +#endif + + _width = _term_width; + + time (&_time_started); + + const po::variables_map map = opts.map (); + + if (map.count ("background")) + _mode = dotline; + + _update_interval = map["update-interval"].as<double>(); +} + +static double to_mb (const double bytes) +{ + return bytes/(1024*1024); +} + +namespace pt = boost::posix_time; + +static std::string to_s (const int secs) +{ + pt::time_duration td = pt::seconds (secs); + return pt::to_simple_string (td); +} + +static std::string to_unit (double& rate) +{ + std::string units = "K/s"; + if (rate >= 1024.0*1024.0*1024.0) + { + rate /= 1024.0*1024.0*1024.0; + units = "G/s"; + } + else if (rate >= 1024.0*1024.0) + { + rate /= 1024.0*1024.0; + units = "M/s"; + } + else + rate /= 1024.0; + return units; +} + +namespace fs = boost::filesystem; + +void +progressbar::update (double now) +{ + time_t tnow; + + time (&tnow); + + const time_t elapsed = tnow - _time_started; + + bool force_update = false; + +#ifdef WITH_RESIZE + if (recv_sigwinch && _mode == normal) + { + const size_t old_term_width = _term_width; + + _term_width = get_term_width (); + + if (!_term_width) + _term_width = default_term_width; + + if (_term_width != old_term_width) + { + _width = _term_width; + force_update = true; + } + + recv_sigwinch = 0; + } +#endif // WITH_RESIZE + + const bool inactive = now == 0; + + if (!_done) + { + if ((elapsed - _last_update) < _update_interval + && !force_update) + { + return; + } + } + else
View file
cclive-0.7.3.tar.gz/src/cclive/re.cpp
Changed
(renamed from cclive/src/re.cpp)
View file
cclive-0.7.3.tar.gz/src/cclive/wait.cpp
Changed
(renamed from cclive/src/wait.cpp)
View file
cclive-0.7.3.tar.gz/src/quvicpp
Added
+(directory)
View file
cclive-0.7.3.tar.gz/src/quvicpp/error.cpp
Changed
(renamed from lib/quvicpp/src/error.cpp)
View file
cclive-0.7.3.tar.gz/src/quvicpp/link.cpp
Changed
(renamed from lib/quvicpp/src/link.cpp)
View file
cclive-0.7.3.tar.gz/src/quvicpp/misc.cpp
Changed
(renamed from lib/quvicpp/src/misc.cpp)
View file
cclive-0.7.3.tar.gz/src/quvicpp/options.cpp
Changed
(renamed from lib/quvicpp/src/options.cpp)
View file
cclive-0.7.3.tar.gz/src/quvicpp/query.cpp
Added
@@ -0,0 +1,161 @@ +/* +* Copyright (C) 2010 Toni Gundogdu <legatvs@gmail.com> +* +* 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/>. +*/ + +#include "config.h" + +#include <cassert> + +#include <quvicpp/quvicpp.h> + +namespace quvicpp +{ + +// Constructor. + +query::query () + : _quvi(NULL), _curl(NULL) +{ + _init(); +} + +// Copy constructor. + +query::query (const query& q) + : _quvi(NULL), _curl(NULL) +{ + _init(); +} + +// Copy assignment operator. + +query& +query::operator=(const query& q) +{ + if (this != &q) + { + _close(); + _init(); + } + return *this; +} + +// Destructor. + +query::~query () +{ + _close(); +} + +// Init. + +void +query::_init () +{ + + const QUVIcode rc = quvi_init(&_quvi); + + if (rc != QUVI_OK) + throw error(_quvi,rc); + + assert (_quvi != NULL); + + quvi_getinfo(_quvi, QUVIINFO_CURL, &_curl); + assert (_curl != NULL); +} + +// Close. + +void +query::_close () +{ + if (_quvi) + quvi_close (&_quvi); // Resets to NULL. + assert (_quvi == NULL); + _curl = NULL; +} + +// Parse. + +video +query::parse (const url& pageURL, const options& opts) const +{ + + // Friend of quvicpp::options class -> clean API. + + if (!opts._format.empty()) + quvi_setopt(_quvi, QUVIOPT_FORMAT, opts._format.c_str()); + + quvi_setopt(_quvi, QUVIOPT_STATUSFUNCTION, opts._statusfunc); + quvi_setopt(_quvi, QUVIOPT_WRITEFUNCTION, opts._writefunc); +#ifdef _0 + quvi_setopt(_quvi, QUVIOPT_NOVERIFY, opts._verify ? 1L:0L); +#endif +#ifdef HAVE_QUVIOPT_NOSHORTENED + quvi_setopt(_quvi, QUVIOPT_NOSHORTENED, opts._shortened ? 1L:0L); +#endif +#ifdef HAVE_QUVIOPT_CATEGORY + quvi_setopt(_quvi, QUVIOPT_CATEGORY, QUVIPROTO_HTTP); +#endif + + quvi_video_t qv; + + QUVIcode rc = + quvi_parse(_quvi, const_cast<char*>(pageURL.c_str()), &qv); + + if (rc != QUVI_OK) + throw error(_quvi,rc); + + assert (qv != NULL); + + video v(qv); + quvi_parse_close(&qv); + + return v; +} + +// Get. + +void* +query::curlHandle () const +{ + return _curl; +} + +// Support. + +std::map<std::string,std::string> +query::support () const +{ + + std::map<std::string,std::string> map; + char *d=NULL, *f=NULL; + + while (quvi_next_supported_website(_quvi, &d, &f) == QUVI_OK) + { + map[d] = f; + quvi_free(d); + d = NULL; + quvi_free(f); + f = NULL; + } + + return map; +} + +} // End namespace + +// vim: set ts=2 sw=2 tw=72 expandtab:
View file
cclive-0.7.3.tar.gz/src/quvicpp/video.cpp
Changed
(renamed from lib/quvicpp/src/video.cpp)
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.