Created
March 1, 2022 16:37
-
-
Save Emersont1/c425fb898531bd3bf9b5218640631d3b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import os | |
from google_drive_downloader import GoogleDriveDownloader as gdd | |
def make_slug(title): | |
long = ''.join([ | |
s if s in '0123456789-abcdefghijklmnopqrstuvwxyz' | |
else '-' | |
for s in title.lower().strip() | |
]) | |
xs = [x for x in long.split("-") if not short_word(x)] | |
return "-".join(xs) | |
def short_word(w): | |
return w in [ | |
"", "the", "a" | |
] | |
data = pd.read_csv('data.csv') | |
try: | |
for d in data.loc: | |
print(d[2]) | |
try: | |
os.mkdir(make_slug(d[2])) | |
except OSError: | |
pass | |
os.mkdir(f"{make_slug(d[2])}/{make_slug(d[3])}") | |
with open(f"{make_slug(d[2])}/{make_slug(d[3])}/description.txt", "w") as desc: | |
desc.write(f"{d[3]}\n{d[5]}\n{d[4]}") | |
if d[7] == "Yes": | |
print(d[8].split("=")[-1]) | |
print(d[8]) | |
gdd.download_file_from_google_drive(file_id=d[8].split("=")[-1], dest_path=f"{make_slug(d[2])}/{make_slug(d[3])}/image.jpg", unzip=False) | |
gdd.download_file_from_google_drive(file_id=d[6].split("=")[-1], dest_path=f"{make_slug(d[2])}/{make_slug(d[3])}/audio.mp3", unzip=False) | |
except KeyError: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
where are the files required for it to run?