git @ Cat's Eye Technologies yastasoti / 67919ee
dest_filename can be used to override the filename it is saved as. Chris Pressey 1 year, 10 months ago
2 changed file(s) with 15 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
4646 EOF
4747 yastasoti --archive-to=downloads links.json
4848
49 #### Override the filename the stuff is archived as ####
50
51 cat >links.json << EOF
52 [
53 {
54 "url": "http://catseye.tc/",
55 "dest_filename": "home_page.html"
56 }
57 ]
58 EOF
59 yastasoti --archive-to=downloads links.json
60
4961 #### Categorize archived materials with a router ####
5062
5163 An archive router (used with `--archive-via`) is a JSON file that looks like this:
180180 def handle_link(self, link):
181181 url = link['url']
182182 dirname, filename = url_to_dirname_and_filename(url)
183 if 'dest_filename' in link:
184 filename = link['dest_filename']
183185 dest_dir = self.select_dest_dir(url)
184186 if dest_dir == '/dev/null':
185187 logger.info(u"{} routed to {}, skipping".format(url, dest_dir).encode('utf-8'))
187189 'status_code': 200
188190 }
189191 dirname = os.path.join(dest_dir, dirname)
190 logger.info(u"archiving {} to {}".format(url, dirname).encode('utf-8'))
192 logger.info(u"archiving {} to {}/{}".format(url, dirname, filename).encode('utf-8'))
191193 if not os.path.exists(dirname):
192194 os.makedirs(dirname)
193195 existing_file = os.path.join(dirname, filename)