gvideo: Fix URI::Escape import error, fix "id not found" error handling.
[clive.git] / clive.pod
blobfc44c7488f6230dd7f3912dde639a2e9c60cb593
1 =head1 NAME
3 clive - the non-interactive video extraction utility
5 =head1 SYNOPSIS
7 clive [option]... [URL]...
9 =head1 DESCRIPTION
11 clive is a command line utility for extracting videos from Youtube and other
12 video sharing Web sites. It was originally written to bypass the Adobe Flash
13 requirement needed to view the hosted videos.
15 clive can be non-interactive. This means it can work in the background
16 while the user is not logged on, allowing the user to start an extraction
17 and disconnect from the system and letting clive finish the work.
19 clive was influenced by the GNU L<wget(1)> utility. Kudos to the wget team
20 for their original work.
22 =head1 OPTION SYNTAX
24 You may freely mix different option styles, or specify options after the
25 command-line arguments. For example:
26   % clive -c --format=mp4 URL -n
28 You may also put several options together that do not require arguments.
29 For example:
30   % clive -pcn URL
32 Which is equivalent to:
33   % clive -p -c -n URL
35 =head1 OPTIONS
37 =over 4
39 =item B<-h --help>
41 Print this help and exit.
43 =item B<-v --version>
45 Print version and exit.
47 =item B<-b --background>
49 Go to background immediately after startup. If no output file is specified
50 using the B<--output> or B<--append>, the output is redirected to I<clive-log>
51 file. Implies B<--progress=>I<dot>.
53 =item B<-e --emit-csv>
55 Do not extract any videos, instead print the video details as CSV to stdout.
56 Ignores the B<--quiet> option for CSV.
58 =item B<-E --emit-xml>
60 Equivalent to B<--emit-csv> in every way but the output is XML. Negates
61 B<--emit-csv>.
63 =item B<-V --clivepass=>I<path>
65 I<path> to the L<clivepass(1)> utility. If CLIVEPASS_PATH environment
66 variable is set, it will will used.
68 =back
70 B<HTTP options>
72 =over 4
74 =item B<-U --agent=>I<string>
76 Identify as I<string> to the HTTP server. Defaults is "Mozilla/5.0".
78 =item B<-y --proxy=>I<address>
80 Use I<address> for HTTP proxy, e.g. http://foo:1234. If undefined,
81 uses the http_proxy environment setting if present.
83 =item B<-X --no-proxy>
85 Do not use HTTP proxy.
87 =back
89 B<Cache Options>
91 =over 4
93 =item B<-R --renew>
95 Renew cache entries for the re-visited URLs. See L</CACHE> in the manual page.
97 =item B<-s --show>
99 Print all cache entries to standard output.
101 =item B<-H --show-format=>I<string>
103 Format printed entries using the I<string>. Default is '%D: "%t" | %mMB'.
104 The following specifiers are supported:
105   %t = video page title
106   %i = video id
107   %l = video file length (bytes)
108   %u = video page url
109   %x = video extraction url
110   %D = video extraction date
111   %T = video extraction time
112   %S = video extraction timestamp (same as: %D %T)
114 =item B<-g --grep=>I<pattern>
116 Grep cache entries for I<pattern>. Matching is B<not> restricted to any
117 specific cache entry field (e.g. title or id).
118   % clive --grep=git
119   % clive --grep=^git --ignore-case
121 The matched entries are then extracted. To only show the matches, use the
122 B<--show> option. For example:
123   % clive -sg ^git
125 =item B<-i --ignore-case>
127 Causes clive to ignore case-differences with B<--grep>.
129 =item B<-D --delete>
131 Delete grep-matched entries from the cache. If used with the B<--show>
132 option, clive will prompt before deleting, e.g.:
133   % clive -siDg ^git
135 =item B<-C --clear>
137 Clear cache and exit.
139 =back
141 B<Logging and Input Options>
143 =over 4
145 =item B<-o --output=>I<logfile>
147 Log all messages to I<logfile>. The messages are normally reported to
148 stdout and stderr.
150 =item B<-a --append=>I<logfile>
152 Append to I<logfile>. This is the same as B<--output> but appends to
153 I<logfile> instead of overwriting it. If the I<logfile> does not exist,
154 it is created.
156 =item B<-d --debug>
158 Causes the program to print Curl debug messages.
160 =item B<-q --quiet>
162 Turn off all output.
164 =item B<-r --recall>
166 Recall the last URL batch from the previous runtime. Note that clive overwrites
167 this information at every runtime. See also L</CACHE>.
169 =item B<-T --savebatch=>I<file>
171 Save current URL batch to I<file>. 
173 =item B<-p --paste>
175 Paste input from clipboard. The pasted URLs are expected to be separated with
176 newlines.
178 =back
180 B<Download Options>
182 =over 4
184 =item B<-O --output-video=>I<file>
186 Write video to I<file>.
188 =item B<-n --no-extract>
190 Do not actually extract any videos.
192 =item B<-c --continue>
194 Continue extraction of a partially downloaded file. Note that this works only
195 with HTTP servers that support the "Range" header. Ignored unless I<localfile>
196 E<lt> I<remotefile>.
198 The "requested range was not delivered" error typically implies that the
199 host does not allow continuing partially extracted video files. You will
200 see this error if you attempt to continue a partially downloaded flv video
201 from Youtube, for example.
203 =item B<-W --overwrite>
205 Causes clive to overwrite already existing video files. By default clive
206 appends a numeric suffix to the output filename.
208 =item B<-G --progress=>I<type>
210 Select the I<type> of the progress indicator. Accepted types are "bar",
211 "dot" and "none".
213 The "bar" indicator is used by default. It spews out some details indicating
214 the status of retrieval. If the output is not a TTY, the "dot" bar will be
215 used instead.
217 Use --progress=dot to switch to the "dot" display. It traces the retrieval
218 by printing dots on the screen, each dot representing a fixed amount of
219 downloaded data.
221 When using the dotted retrieval, you may also set the style by specifying
222 the I<type> as dot:style.
223   --progress=dot:default
224     each dot 1K, 10-dots clusters, 50-dots lines
225   --progress=dot:binary
226     each dot  8K, 16-dots clusters, 48-dots lines
227   --progress=dot:mega
228     each dot 64K,  8-dots clusters, 48-dots lines
230 Progress indication can be disabled completely by setting I<type> to "none".
232 =item B<-u --youtube-user=>I<username>
234 I<username> to log into Youtube. Typically needed only if you are planning
235 to extract videos flagged as mature-content.
237 =item B<-t --youtube-pass=>I<password>
239 I<password> to log into Youtube. If I<password> is "-", causes clive to
240 retrieve the login password from the L<clivepass(1)> utility. See L</EXAMPLES>.
242 =item B<-L --no-login>
244 Do not log into Youtube.
246 =item B<-S --savedir=>I<dir>
248 Save extracted videos to I<dir>.
250 =item B<-f --format=>I<format>
252 Extract I<format> of the video. All supported websites have at least the flv
253 format available. See L</FORMATS> for more.
255 =item B<-l --cclass=>I<character-class>
257 Use I<character-class> to filter the video page titles. Default is B<\w>.
258 The filtered video page titles are used to name the extracted videos.
260 =item B<-N --filename-format=>I<string>
262 Use I<string> to construct the name of the extracted video. Default is
263 "%t_%d_%i.%s". The following specifiers are supported:
264   %t = video title (after applying --cclass)
265   %i = video id
266   %d = video domain
267   %s = video suffix
268   %D = current date
269   %T = current time
270   %S = timestamp (same as %D %T)
272 =item B<-x --exec=>I<command>B<;>
274 Execute I<command>. Optional arguments may be passed to the command.
275 The expression must be terminated by a semicolon (";"). If the specifier
276 "%i" appears anywhere in I<command> name or the arguments it is replaced
277 by the pathname of the extracted video file.
279 Example:
280   % clive --exec="mplayer %i;" URL
282 =item B<-x, --exec=>I<command>B<+>
284 Same as B<--exec>, except that "%i" is replaced with as many pathnames
285 as possible for the invocation of I<command>.
287 =item B<--stream-exec=>I<command>
289 Execute I<command> when file transfer progress reaches I<percent> as defined
290 with the B<--stream> option. The "%i" specifier for video pathname is expected
291 to appear somewhere in the I<command> expression.
293 Unlike the B<--exec> option which is executed subsequently after each file
294 transfer, B<clive> forks the streaming process and continues with the file
295 transfer -- and will not continue to download another file until the child
296 process terminates.
298 It should also be noted that B<clive> makes no effort to check whether there
299 is enough data to be streamed. It assumes the user knows how much data needs
300 to be buffered before starting the child process. Similarly, if the transfer
301 rate drops significantly after starting the process and it runs out of data,
302 B<clive> simply ignores that.
304 Some players and formats may not work properly with this feature. Try
305 L<mplayer(1)> and choose flv if you are unsure.
307 =item B<--stream=>I<percent>
309 Execute the I<command> defined with the B<--stream-exec> option when the file
310 transfer progress reaches I<percent>.
312 Example:
313   % clive --stream-exec="mplayer -really-quiet %i" --stream=20 URL
315 =back
317 =head1 EXAMPLES
319 =over 4
321 =item Typical use:
323 % clive "http://youtube.com/watch?v=3HD220e0bx4"
325 =item Multiple video URLs:
327 % cat E<gt>E<gt> url.lst
328   http://en.sevenload.com/videos/IUL3gda-Funny-Football-Clips
329   http://youtube.com/watch?v=3HD220e0bx4
330   http://break.com/index/beach-tackle-whip-lash.html
331   http://www.liveleak.com/view?i=704_1228511265
333 % cat url.lst | clive
335 =item Combine input from multiple sources:
337 % clive -p URL URL2
339 =item Recall the last URL batch, extract mp4 video format:
341 % clive -rf mp4
343 =item Grep for the pattern in cache, extract matched videos:
345 % clive -g 3HD220e0bx4
347 =item Same as above but I<delete> the matched entries from cache:
349 % clive -iDg ^3hd2
351 Note the use of -i (--ignore-case).
353 =item Print cache contents to stdout:
355 % clive -s
357 =item Combine matching and printing cache entries:
359 % clive -sig ^3hd2
361 Note that -s negates video extraction.
363 =item Match, redirect output to I<my.log>, go to background:
365 % clive -big ^3hd2 -o my.log
367 =item Extract video from URL, re-encode audio to mp3:
369 % clive --exec="ffmpeg -y -i %i %i.mpg;" URL
371 =item Login to Youtube to extract a video:
373 % clive -u myusername -t mypassword URL
375 This isn't typically needed unless you are trying to extract videos flagged
376 as mature content.
378 =item Use protected login password:
380 Otherwise same as above but the login info is saved to a clivepass password
381 repository file. The saved passwords are encrypted.
383 Note that you will need to install the clive-utils for this. See the L</OTHER>
384 section for details.
386 Create new password repository:
387   % clivepass --create
389 Add new login name "myusername":
390   % clivepass --add myusername
392 Use the created login info from clive:
393   % clive -u myusername -t - -V /usr/bin/clivepass URL
395 This causes B<clive> to request for the login password for "myusername" from
396 L<clivepass(1)>. The password is then used to login to Youtube before extracting
397 the video from the URL.
399 =back
401 =head1 FORMATS
403 clive defaults to extract the flv format unless the B<--format> option is
404 used. The requested format may not always be available. The server typically
405 returns one of the HTTP/40x errors if the requested format is not available.
407 The quality of the video depends on the uploaded video quality. Each website
408 typically recompresses the uploaded videos to 320x240 resolution (sometimes
409 higher). Because this varies per video and website, you should treat the
410 list below only as a rough reference of what formats should be available.
412 =over 4
414 =item B<www.youtube.com>
416 =item B<www.last.fm>
418 Formats: (flv|mp4|3gpp|xflv)  Continue: Yes (except flv)
420 mp4 and 3gpp formats are typically, or will become later, available.
421 xflv appears to be very rare. Videos dating back to 2006 may only be
422 available as flv.
424 Some of the videos displayed on last.fm site are actually Youtube videos.
425 You can pass the lastfm'ed video URLs to B<clive>.
427 =back
429 =over 4
431 =item B<video.google.com>
433 Formats: (flv|mp4)  Continue: Only mp4
435 The mp4 may not always be available. GoogleVideo mp4 are encoded using a
436 different codec than Youtube mp4 videos. You can typically B<--stream-exec>
437 Youtube mp4 videos but this is not case with GoogleVideo mp4 videos. If you
438 find a way, drop an email.
440 =back
442 =over 4
444 =item B<www.sevenload.com>
446 Formats: flv  Continue: Yes
448 =back
450 =over 4
452 =item B<www.break.com>
454 Formats: flv  Continue: Yes
456 =back
458 =over 4
460 =item B<www.liveleak.com>
462 Formats: flv  Continue: Yes
464 =item B<www.evisor.tv>
466 Formats: flv  Continue: Yes
468 =item B<www.dailymotion.com>
470 Formats: (spark|spak-mini|vp6-hq|vp6-hd|vp6|h264)  Continue: Yes
472 spark is the "regular" 320x240 flv. B<clive> defaults to spark
473 if requested format is not available.
475 =back
477 =head1 CACHE
479 The cache has two purposes:
481 =over 4
483 =item 1.
485 Keep reusable video data available for fast re-extraction.
487 =item 2.
489 Keep a record of extracted videos.
491 =back
493 Each cache entry contains information about a video, including, but not limited
494 to, page title, file length and extraction URL. You can use the B<--grep> option
495 to match these details when you are searching for videos from the cache. See
496 the L</EXAMPLES> section for examples of how to do this.
498 Some entries may need to be renewed from time to time as certain websites have
499 their extraction URLs expire after awhile. Youtube is an example of this.
500 Youtube servers usually return the HTTP/410 error if the extraction URL has
501 expired. You can use the B<--renew> option to fix this.
503 Note that B<clive> renews the cache entry automatically if the video format
504 does not match the cached video format string. This is done for two reasons:
506 =over 4
508 =item 1.
510 Cached video extraction URL points to a different location
512 =item 2.
514 Cached video file length is likely to be incorrect
516 =back
518 =head1 UNICODE
520 The author has had some success with L<uxterm(1)> previously. Truth to be told,
521 this is by far one of the least favorite topics of mine. I blame Python (partly)
522 for this. See your local unicode-expert on this.
524 My two cents: As long as the terminal is unicode capable and the used terminal
525 font supports the characters, this shouldn't be a problem. You may want to use
526 B<--cclass>=. when you are running tests. That disables video title filtering.
528 =head1 FILES
530 clive searches the ~/.config/clive directory for the config file. You can
531 override this by setting the B<CLIVE_HOME> environment variable.
533 =over 4
535 =item ~/.config/clive/config
537 Configuration file for clive.
539 =item ~/.config/clive/cache
541 Contains the cache entries of the visited URLs. A Berkeley DB (Hash) file.
543 =item ~/.config/clive/recall
545 Contains the last URL batch. You can B<--recall> this file.
547 =back
549 =head1 SEE ALSO
551 L<clivefeed(1)> L<clivescan(1)> L<clivepass(1)>
553 =head1 OTHER
555 Homepage:
556   <http://clive.sourceforge.net/>
558 Project page:
559   <http://code.google.com/p/clive/>
561 Development repository can be cloned with:
562   % git clone git://repo.or.cz/clive.git
564 For release announcements, subscribe to the project at:
565   <http://freshmeat.net/projects/clive/>
567 Additional utilities (clive-utils):
568   <http://code.google.com/p/clive-utils/>
570 =head1 AUTHOR
572 Written by Toni Gundogdu <legatvs@gmail.com>.
574 =cut