Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the functionality of the extension automatic-save-folder #75

Open
ziceptor opened this issue Sep 8, 2019 · 3 comments
Open
Labels
enhancement New feature or request P3 Priority 3

Comments

@ziceptor
Copy link

ziceptor commented Sep 8, 2019

This will allow to manage downloads with regexp.
http://asf.mangaheart.org/
https://github.com/cyan06/automatic-save-folder

@nmaier
Copy link
Member

nmaier commented Sep 8, 2019

I have no idea what this is.
Can you elaborate please?

@nmaier nmaier added enhancement New feature or request unconfirmed labels Sep 9, 2019
@ziceptor
Copy link
Author

ziceptor commented Sep 9, 2019

Аutomatically select the save folder (local destination folder) based on filters.

Requires #18





You can insert dynamic variables in your filter's save path, such as the date of the day, the website name, etc.

You need to enable dynamic folder creation in the option's tab to allow manual edition of the save paths.

Attention : Uppercase and lowercase are different tags.
Year
%Y% = 2009, 2012
%y% = 09, 12
	Month
%m% = 01 to 12
%n% = 1 to 12
%F% = January
%M% = Jan
	Week
%W% = 01 to 52
	Day
%d% = 01 to 31
%j% = 1 to 31
%w% = 0 (Sunday) to 6
%l% = Monday
%D% = Mon

Special tags :
%asf_D%	= Domain name. (Without http://)
%asf_F%	= File name with the extension.
%asf_Fx%	= File name without the extension.
%asf_d%	= "Domain" field from the used filter. (Forbidden characters will be deleted. If no filter is found, the current domain is used)
%asf_f%	= "File name" field from the used filter. (Forbidden characters will be deleted. If no filter is found, the current file name is used)
%asf_x%	= File extension. (Without the dot)

Capture tags :
$[number]d = Return the captured data using parentheses in the "domain" filter. [number] refer to the parenthesis number, from 1 to 9.

$[number]f = Return the captured data using parentheses in the "file name" filter. [number] refer to the parenthesis number, from 1 to 9.
Example, on this filter: mozilla_(firefox)_3.5.(exe), $1f will capture firefox, and $2f will capture "exe".

%asf_rd%regular expression%asf_rd%
Check the domain with the regular expression contained between the two tags %asf_rd% and return the captured data.

%asf_rf%regular expression%asf_rf%
Check the file name with the regular expression contained between the two tags %asf_rf% and return the captured data.

ATTENTION : If the result for the saving path has forbidden characters (the : or the ?"*\/<>|: under Windows), the extension will cease to function. Be sure to check your filters if the extension doesn't work anymore.
How to use

This extension allows you to define, using filters, the folder which will be automatically chosen while saving your files.
Filter rules

    The filters are defined using the file's name and the domain.
    The filters have to match the name of the file or the domain. For example do not write "google.com" but only google.com (without quotes)
    You can use the wildcard character * (asterisk) to replace parts of the filter: wiki*.org
    The asterisk is not needed at the beginning and end of the filter string. Writing *wiki* or wiki is the same.
    Same thing with the filename filter: *.zip or .zip will work the same way.
    The filters are verified from top to bottom and the process stops when a filter matching the downloaded file is met. Be sure to sort your filters accordingly.
    The filters are case insensitive, there is no difference between upper and lower case while the filters are processed.


For more flexibility, this extension accept regular expressions.
To get help with regular expression you can go to the 'add and edit filter' window, which is also available on the add-on main website or you can read this one for complete resources http://www.regular-expressions.info/.

Dynamic variables can be used to create new folders when saving, named after the date of the day, the file name, domain name, etc.
You can go to the Dynamic Folders tab to see the available tags.


Few filters examples

    If you want all your executable files .exe to be saved in a specific folder:
    Domain : All
    File : .exe
    Folder : The folder you want your executable files to be saved to.


    Now if you want all the files from a particular website (mozilla.org for example) to be saved in a Mozilla folder:
    Domain : mozilla.org
    File : All
    Folder : Your Mozilla folder.


    Then, if you need to sort all .zip files from mozilla.org, and leaves other files in the previous folder:
    Domain : mozilla.org
    File : .zip
    Folder : Your Mozilla folder for .zip files.
    And sort this filter above the previous one. Do remember the filters are verified from top to bottom.


    And last, you can define filters with more complete name, not only with the file extension:
    Domain : All
    File : firefox*.exe
    Folder : Your folder for all version of Firefox installation program.


Here are a few examples with Dynamic filters and Capturing filters
Attention : In order to work correctly, don't forget to enable the option on the Dynamic Filters tab

    Dynamic filter
    To sort out all the nightly builds of firefox in a sub-folder of D:\Download\firefox:
    Domain : All
    File : firefox*pre
    Folder : D:\Download\firefox\nightly\%Y%-%m%-%d%
    The extension will create a sub-folder named after the date of the day. For example "2009-12-04", in which your file will be saved.


    Dynamic filter
    To sort out a file according to its extension:
    Domain : All
    File : All
    Folder : D:\Download\%asf_x%
    The extension will create a sub-folder named "zip" for the .zip files, "rar" for .rar files, etc. in which your file will be saved.


    Capture Filter
    To sort all the Firefox installation package inside subfolder named after the software version:
    Domain : All
    File : Firefox Setup (*).exe
    Folder : D:\Download\Firefox\$1f
    While checking the downloaded file with the filters, the parentheses are not took in account, and the filter will act as "Firefox Setup *.exe"
    $1f correspond to the first parenthesis content on the filter's file name, which is the version number
    The file "Firefox Setup 3.5.4.exe" will be saved in the folder D:\Download\Firefox\3.5.4\


    Capture Filter
    To create or not create different subdirectories according to the name of the file:
    Example : We wish to download videos named "My_vacation_date-of-the-trip.avi".
    The videos have .srt subtitles to explain the trip, .zip files are also available with photos of the trip, videos can be downloaded with .avi, .torrent or .nzb extension (newsgroup).

    ".avi" and ".srt" will have to go in the D:\video\vacation file.
    ".zip", ".torrent" and ".nzb" will have to go respectively in subdirectories D:\video\vacation\zip, D:\video\vacation\torrent and D:\video\vacation\nzb.

    Domain : All
    File : /^My_vacation.*\.(avi|srt|zip|torrent|nzb)$/
    Folder : D:\video\vacation\%asf_rf%(zip|torrent|nzb)$%asf_rf%

    Explanation about the filters:
    The filter will be activated for all the files beginning with "My_vacation" and ending with one of the available extensions (avi, srt, zip, torrent or nzb).
    The directory created will depend on the filtering : %asf_rf% analyses the name of the file downloaded with the regular expression contained between the two %asf_rf% : If the file ends with "zip", "torrent" or "nzb", the portion captured by the regular expression creates the subdirectory.
    If none of those three extensions are found, the regular expression won't do anything, no sub-folder is created and files will be downloaded in D:\video\vacation\

    Note : You can put as many tags as you want for the main folder.
    The filter could have been:
    D:\video\%asf_rf%(vacation|wedding)%asf_rf%\%asf_rf%(zip|torrent|nzb)$%asf_rf%
    In this case, the sub-folder "vacation" is created only if the name of the file contains "vacation". 

@nmaier
Copy link
Member

nmaier commented Sep 9, 2019

Well, I cannot do #18 anyway at the moment, as browsers won't let me.

As for some basic automated sorting, you can use the renaming mask for that. It is not as powerful as that extension you were using, apparently, but maybe better than nothing.

E.g. a mask of *y*/*m*/*ext*/*name*.*ext* would create the directories 2019/09/png/ and the file file.png and similar.

It is rather unlikely that I will implement the full spectrum of options and ways to assign paths to downloads, but I'll leave this open so I can look for it as an inspiration.

I think it would be reasonable to add some dynamic renaming mask tags that can be configured based on filters similar to that extension for example.

@nmaier nmaier added P3 Priority 3 and removed unconfirmed labels Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P3 Priority 3
Projects
None yet
Development

No branches or pull requests

2 participants