DR

Downloads Router Configuration

(v0.8.1) Sept. 30, 2014: Bug fixes and fallback cases for referrer- and MIME-rules.

Routing rules

Please provide destination folders delimited by forward slash (/).
Destinations must be located within the base downloads folder; use symbolic links to circumvent this restriction (see usage instructions).

Rule execution hierarchy

Specify the order in which you would like the tables taversed.
Default is filename, referrer, mime.

Filetype ⇨ folder mapping

Filetype (MIME)Destination folder

Referrer ⇨ folder mapping

Enable this checkbox to make all downloads (not preceded by another explicit rule) be stored in a folder with the same name as the source domain.

Source domainDestination folder
  • Do not include http:// or www. Other subdomains, such as images.domain.com, are required.
  • Larger websites often utilize Content Distribution Networks, which means that the referrer for a certain image might not be the same as the domain of the website you are visiting. Facebook, for instance, uses the Akamai network to serve images.

Filename ⇨ folder mapping

Filename keywordDestination folder

* Keywords are case-insensitive. Recommended basic usage is a single keyword per rule. Further guidelines are available on the "Usage instructions" page. The keyword is treated directly as a regular expression — feel free to experiment.

Common MIME types

This table contains a few common MIME types that might help you set up your routing configuration. A more extensive list is available on Wikipedia.

application/pdfPDF documents
application/zipCompressed archives
application/x-bittorrentTorrent files
application/exeWindows executable
audio/mpegMP3 and other MPEG audio
image/gifGIF images
image/jpegJPEG images
image/pngPNG images
video/x-msvideoAVI video

Advanced filename keywords

A few helpful tricks for more powerful filename-based routing.

a|b"|" is an else operator
Matches "a" or "b".
a.b"." is a single-character wildcard
Matches "a-b", "a_b", "a b", etc.
a.*b".*" multi-character wildcard
Matches "a" followed by anything then followed by "b".

Usage instructions

Important information

Due to security concerns (see the chrome.downloads API), Chrome extensions are only allowed to download files to targets within the default downloads directory. You may manually circumvent this restriction by creating a "symbolic link" (more info) from within the downloads directory to any other direction on your harddrive(s).

Symlinks on Windows (XP, Vista, 7, 8)

  1. Open the command prompt (cmd.exe) as Administrator
    Search for cmd in the start menu, right-click and choose 'Run as Administrator'
  2. Create the symbolic link: mklink /D TARGET LINK
    Substitute TARGET for the link name within Downloads, and LINK to your desired download destination
    • Example: mklink /D "C:\Users\MyName\Downloads\Music" "D:\Music"
  3. Configure Downloads Router, setting your Destination folder to TARGET.
    • Example: Filetype (MIME) = audio/mpeg, Destination folder = Music/

Symlinks on Linux and Mac

  1. Open a terminal
  2. Create the symbolic link: ln -s TARGET LINK_NAME
    TARGET is your desired download destination, LINK_NAME is the link within Downloads
    • Example: ln -s /home/myname/music /home/myname/Downloads/music
  3. Configure Downloads Router, setting your Destination folder to LINK_NAME.
    • Example: Filetype (MIME) = audio/mpeg, Destination folder = music/

Downloads Router's configuration (paths and rules) never require quotation marks.

Referrer routing

A referrer is a website, such as facebook.com or 9gag.com.

You do not need to provide the protocol prefix (http://), nor the www subdomain. Any other subdomain, however, such as images.domain.com, IS a required part of the "source domain" field.

Please note that some larger websites, such as Facebook, utilize Content Distribution Networks, which means that the referrer of the file you wish to download is a different domain. To verify if this is the case, right-click the element in question and check the source of the file.

Filetype (MIME) routing

The MIME type is an identifier of the type of data that a file contains, and thus somewhat different from an extension (such as .pdf, or .png).

The routing rules page provides a table with some common MIME types, and a more exhaustive list can be found on Wikipedia.

Sometimes web servers distribute files as application/octet-stream rather than the "correct" MIME-type. Workarounds for the most common types have been implemented and should solve this issue automatically, but if you encounter problems, please attempt to use either of the other routing options to avoid this issue.

Filename routing

Route to target folder based on case-insensitive keyword(s) in the filename, using regular expressions.

Please note that the matching is performed on a substring level, meaning that, for instance, the keyword "jet" would trigger the rule on downloads with filenames like "jetski" or "jumbojet."

The asterisk (*) is not used as a wildcard on its own, as is common in search engines; in regular expressions, it means "the previous statement zero or more times."

You may use the "or" operator | to route a file containing either "ebook" or "epub" by specifying "ebook|epub".

The period (.) is used as a wildcard matching any single character, including whitespaces, dashes, and so forth. Thus, "some.keyword" would match "some keyword" as well as "some_keyword". Powerusers may attempt to write more advanced regular expressions, but such usage has not been tested.

A note on back references

At the present, Downloads Router does not support back references for automatically creating new downloads folders. This might be implemented in future versions.

Troubleshooting

Not working as intended? Here's some common issues. Please get in touch if you think your trouble lies elsewhere!

Files not downloading to the given destination directory
  • The most common error is an invalid download path, such as a path outside of the downloads folder.
    Open the extension's background page (chrome://extensions > background page) and attempt to download the file again with the "Console" tab open. The following message indicates an invalid target path: Error in respose handler for downloadsInternal.determineFilename: Invalid filename at …
Domain-based routing
  • Some websites serve content through other domains than what is visible in the Omnibar. To verify if this might be your issue, right-click the item and "inspect" it – look for other domains in the highlighted area.
MIME-based routing
  • Some websites serve binary content as "octet-streams," thereby hiding the correct MIME-type. The plugin automatically attempts to match common extensions, but this approach will not cover all cases. Domain-based routing could serve as a workaround in many cases.
Filename-based routing
  • "Greedy" matches, i.e. too general keywords matching on unintended downloads, or invalid regular expressions would be two common error causes. For the latter, check the console and/or the extension background page for debugging information.

About this extension

This extension was hacked together overnight by yours truly, during the wee hours most sane people spend sleeping. As such, there are certainly many features I've yet to think about, not to mention bugs waiting to be discovered.

I'd be most grateful if you'd inform me of any and all such issues via the project source code repository — and if you feel like adding some code yourself, that'd be beyond awesome!

Gravatar

Best regards,
— Fredrik Karlström

Licence

Copyright (c) 2014 Fredrik Karlström

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.