Skip to content

Commit

Permalink
- Modify PDF to link to download PDF files
Browse files Browse the repository at this point in the history
- Update SMC to use openpyxl instead of xlrd
  • Loading branch information
frankyrumple committed Apr 26, 2021
1 parent f11c29c commit b34a92a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ webvtt-py
langcodes
bs4
pdfkit
# Make sure to install wkhtmltopdf
lxml
16 changes: 13 additions & 3 deletions web2py/applications/smc/controllers/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -2677,10 +2677,20 @@ def web_to_link_download_doc(current_course_name, link_url):

target_file = os.path.join(target_folder, file_guid).replace("\\", "/")

original_file_name = link_url + '.pdf'
# For links that are NOT PDF already, do pdfkit
if not link_url.lower().endswith('.pdf'):
original_file_name = link_url + '.pdf'

# PDF conversion of web link.
pdfkit.from_url(link_url, target_file)
# PDF conversion of web link.
pdfkit.from_url(link_url, target_file)
else:
# This is a PDF file, just download it.
original_file_name = link_url
req = requests.get(link_url, stream=True)
with open(target_file, 'wb') as f:
for block in req.iter_content(1024):
f.write(block)


# # Download the file
# try:
Expand Down

0 comments on commit b34a92a

Please sign in to comment.