sparkmicro / Ki-nTree

Fast part creation for KiCad and InvenTree
GNU General Public License v3.0
178 stars 33 forks source link

Fix problems with redirects for datasheet links #233

Closed T0jan closed 3 months ago

T0jan commented 4 months ago

@eeintech the first idea on how to tackle #207 and #230. I kept it really basic for now as I only discovered problems with TI parts in the last months, if you prefer a more sophisticated solution let me know

eeintech commented 4 months ago

Thanks @T0jan I'll have to review this a bit later 😄

eeintech commented 3 months ago

@T0jan I won't have time to test but I have put a couple comments in your proposal. Also I need to figure out why the Mouser API is failing on main branch...

eeintech commented 3 months ago

Hello @T0jan I just tested it and it works well for downloading and attaching datasheet to parts on InvenTree. However there is also a feature to download the datasheet in a local folder and this part hasn't been updated and it fails the download:

image

image

I think a more generalized approach and updating the download method in common > tools.py is better suited for post-processing URLs, what do you think?

T0jan commented 3 months ago

@eeintech you are right, completely forgot the local download in my try to keep the renaming and the redirect in one function, which is completely unnecessary. Moved the redirect part to the download function in tools.py

eeintech commented 3 months ago

Hello @T0jan I allowed myself to tackle one layer further in https://github.com/sparkmicro/Ki-nTree/pull/246 I still had issue with how datasheets were managed in the codebase, for instance having to download the same file twice. So now I have added checks for server upload and local datasheet flags in order to not duplicate this operation. Thanks a lot for the great work I will merge #246 directly into main 😃