harsilspatel / moodle-downloader

a 4.9-star chrome extension for batch downloading moodle resources 💾
https://chrome.google.com/webstore/detail/moodle-downloader/ohhocacnnfaiphiahofcnfakdcfldbnh
MIT License
99 stars 15 forks source link

Does not recognise files reliably #3

Closed ehausen closed 5 years ago

ehausen commented 5 years ago

Hello,

This plugin has a very nice idea! I tried it out, but unfortunately it does not recognise files reliably. For me one course for example it only recognises PDF files, but not the excel files.

The problem seems to be the way you are trying to filter only files from all the links by looking for "File" in instancename: https://github.com/harsilspatel/MoodleDownloader/blob/0882f38c7475a5b1a0ceeb509e37576e58935c19/src/background.js#L10-L12

But it turns out that all the download links do not have this instancename.

But I think all the uploaded files seem to have url of with /resource/ in it: ex: /moodle/mod/resource/view.php?id=12345

links seem to have: /moodle/mod/url/view.php?id=12345 assignments: /moodle/mod/assign/view.php?id=12345

So maybe looking for resource in the URL would be more reliable. BUT - I don't know if this url structure is the same in all the Moodle versions, or if it's standard or configurable etc.

harsilspatel commented 5 years ago

Hello ehausen,

Thankyou for raising the issue, I will definitely look into it and make it compatible with more files. I will try out your suggestion, thanks again!

ehausen commented 5 years ago

Maybe this is relevant. http://xref-diff.mukudu-dev.net/moodle26/_functions/set_docs_path.html Not sure

ehausen commented 5 years ago

Hey! Just saw that file (resource?) links are inside an element that has classes class="activity resource modtype_resource "

Links seem to have class="activity url modtype_url "

Of course not sure if all resources are always downloadable files

harsilspatel commented 5 years ago

Hey! Just saw that file (resource?) links are inside an element that has classes class="activity resource modtype_resource "

You're correct! 😄 I think that'll do? I'll try it out, thanks!

harsilspatel commented 5 years ago

Could you please try out the latest release and let me know if it is working as intended?

ehausen commented 5 years ago

Works for me now, at least this course and one other. Not sure of course if there are some situations where modtype_resource could be something else than downloadable file.

One thing though. Excel files display names in the list now miss 4 letters in the end (see image). screen shot 2018-12-30 at 16 34 27 It's of course because .slice(0, -4) in: https://github.com/harsilspatel/MoodleDownloader/blob/8fe70138d69c545744483e3d3b0d5c7466d0ce83/src/background.js#L12

harsilspatel commented 5 years ago

Fixed it! Thanks for all the issues you've raised @ehausen