Today we have released mozdownload 1.18 to PyPI. The reason why I think it’s worth a blog post is that with this version we finally added support for a sane API. With it available using the mozdownload code in your own script is getting much easier. So there is no need to instantiate a specific scraper anymore but a factory scraper is doing all the work depending on the options it gets.
Here some examples:
from mozdownload import FactoryScraper scraper = FactoryScraper('release', version='40.0.3', locale='de') scraper.download()
from mozdownload import FactoryScraper scraper = FactoryScraper('candidate', version='41.0b9', platform='win32') scraper.download()
from mozdownload import FactoryScraper scraper = FactoryScraper('daily', branch='mozilla-aurora') scraper.download()
If you are using mozdownload via its API you can also easily get the remote URL and the local filename:
from mozdownload import FactoryScraper scraper = FactoryScraper('daily', branch='mozilla-aurora') print scraper.url print scraper.filename
Hereby the factory class is smart enough to only select those passed-in options which are appropriate for the type of scraper. If you have to download different types of builds you will enjoy that feature given that only the scraper type has to be changed and all other options could be still passed-in.
We hope that this new feature will help you by integrating mozdownload into your own project. There is no need anymore by using its command line interface through a subprocess call.
The complete changelog can be found here.