Skip to content

Commit

Permalink
Add pseudo-hash to the filename
Browse files Browse the repository at this point in the history
Adds a pseudo-hash to the filename of downloaded lectures based on their
filename on the ETH CDN.

This fixes the issue of not downloading mutliple lectures if they share
a local filenname

Closes #3
  • Loading branch information
gteufelberger committed Sep 18, 2020
1 parent ff6ec7e commit dd12de3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions vo-scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,13 @@ def vo_scrapper(vo_link, user, passw):
# Append date
episode_title = item['createdAt'][:-6]+episode_title

# Filename is `directory/<video date (YYYY-MM-DD)><leftovers from video title>_<quality>.mp4`
# Generate a pseudo hash by using part of the filename of the online version (which appears to be a UUID)
pseudo_hash = video_src_link.replace('https://oc-vp-dist-downloads.ethz.ch/mh_default_org/oaipmh-mmp/','')[:8]
print_information(pseudo_hash, verbose_only=True)

# Filename is `directory/<video date (YYYY-MM-DD)><leftovers from video title>_<quality>-<pseudo_hash>.mp4`
directory = directory_prefix + lecture_title + os.sep
file_name = directory+episode_title+"_"+video_quality+".mp4"
file_name = directory+episode_title+"_"+video_quality+"-"+pseudo_hash+".mp4"
print_information(file_name, verbose_only=True)

local_video_src_collection.append((file_name, video_src_link, episode_name))
Expand Down

0 comments on commit dd12de3

Please sign in to comment.