aboutsummaryrefslogtreecommitdiff
path: root/doc/tips/using_the_web_as_a_special_remote.mdwn
blob: 5e066c91837c4d4f05c5e0228ca0e5edde043d95 (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
The web can be used as a [[special_remote|special_remotes]] too.

	# git annex addurl http://example.com/video.mpeg
	addurl example.com_video.mpeg (downloading http://example.com/video.mpeg)
	########################################################## 100.0%
	ok

Now the file is downloaded, and has been added to the annex like any other
file. So it can be renamed, copied to other repositories, and so on.

To add a lot of urls at once, just list them all as parameters to
`git annex addurl`.

## trust issues

Note that git-annex assumes that, if the web site does not 404, and has the
right file size, the file is still present on the web, and this counts as
one [[copy|copies]] of the file. If the file still seems to be present 
on the web, it will let you remove your last copy, trusting it can be
downloaded again:

	# git annex drop example.com_video.mpeg
	drop example.com_video.mpeg (checking http://example.com/video.mpeg) ok

If you don't [[trust]] the web to this degree, just let git-annex know:

	# git annex untrust web
	untrust web ok

With the result that it will hang onto files:

	# git annex drop example.com_video.mpeg
	drop example.com_video.mpeg (unsafe) 
	  Could only verify the existence of 0 out of 1 necessary copies
	  Also these untrusted repositories may contain the file:
	  	00000000-0000-0000-0000-000000000001  -- web
	  (Use --force to override this check, or adjust numcopies.)
	failed

## attaching urls to existing files

You can also attach urls to any file already in the annex:

	# git annex addurl --file my_cool_big_file http://example.com/cool_big_file
	addurl my_cool_big_file ok
	# git annex whereis my_cool_big_file
	whereis my_cool_big_file (2 copies) 
  	00000000-0000-0000-0000-000000000001 -- web
   	27a9510c-760a-11e1-b9a0-c731d2b77df9 -- here

## configuring filenames

By default, `addurl` will generate a filename for you. You can use
`--file=` to specify the filename to use.

If you're adding a bunch of related files to a directory, or just don't
like the default filenames generated by `addurl`, you can use `--pathdepth`
to specify how many parts of the url are put in the filename.
A positive number drops that many paths from the beginning, while a negative
number takes that many paths from the end.
	
	# git annex addurl http://example.com/videos/2012/01/video.mpeg
	addurl example.com_videos_2012_01_video.mpeg (downloading http://example.com/videos/2012/01/video.mpeg)
	# git annex addurl http://example.com/videos/2012/01/video.mpeg --pathdepth=2
	addurl 2012_01_video.mpeg (downloading http://example.com/videos/2012/01/video.mpeg)
	# git annex addurl http://example.com/videos/2012/01/video.mpeg --pathdepth=-2
	addurl 01_video.mpeg (downloading http://example.com/videos/2012/01/video.mpeg)

## videos

<a name=videos></a>

There's support for downloading videos from sites like YouTube, Vimeo,
and many more. This relies on [youtube-dl](https://rg3.github.io/youtube-dl/)
to download the videos.

When you have youtube-dl installed, you can just 
`git annex addurl http://youtube.com/foo` and it will detect that
it is a video and download the video content for offline viewing.

Later, in another clone of the repository, you can run `git annex get` on
the file and it will also be downloaded with youtube-dl. This works
even if the video host has transcoded or otherwise changed the video
in the meantime; the assumption is that these video files are equivalent.

There is an `annex.youtube-dl-options` configuration setting that can be used
to pass parameters to quvi. For example, you could set `git config
annex.youtube-dl-options "--format worst"` to configure it to download low
quality videos from YouTube. Note that the youtube-dl configuration files
are not read when git-annex runs youtube-dl, to avoid config settings that
break its integration.

To download a youtube channel, you need to find the RSS feed associated with
that channel, and pass it to `git annex importfeed`. There does not seem to
be an easy link anywhere to get the RSS feed, but you can construct its url
manually. For a channel like
"https://www.youtube.com/channel/$foo", the
feed is "https://www.youtube.com/feeds/videos.xml?channel_id=$foo"

## bittorrent

The [[bittorrent_special_remote|special_remotes/bittorrent]] lets git-annex
also download the content of torrent files, and magnet links to torrents.

You can simply pass the url to a torrent to `git annex addurl`
the same as any other url.

You have to have [aria2](http://aria2.sourceforge.net/) 
and bittornado (or the original bittorrent) installed for this
to work.

## podcasts

This is done using `git annex importfeed`. See [[downloading podcasts]].