* tools file name change to utils

* Seperate downloaders (#94)

* Seperated the downloaders

* Remove redundant code

* Changed file names

* refactor

* Redgifs (#95)

* Init commit

* Init commit

* GifDeliveryNetwork (#96)

* Initial commit

* Gfycat forwarding to GDN bug fixed
This commit is contained in:
Ali Parlakçı
2020-05-28 21:42:11 +03:00
committed by GitHub
parent c5a2eed80f
commit 148e20d1d6
14 changed files with 733 additions and 550 deletions

32
src/downloaders/Direct.py Normal file
View File

@@ -0,0 +1,32 @@
import os
from src.downloaders.downloaderUtils import getFile, getExtension
from src.errors import FileNameTooLong
from src.utils import nameCorrector
from src.utils import printToFile as print
class Direct:
def __init__(self,directory,POST):
POST['postExt'] = getExtension(POST['postURL'])
if not os.path.exists(directory): os.makedirs(directory)
title = nameCorrector(POST['postTitle'])
"""Filenames are declared here"""
print(POST["postSubmitter"]+"_"+title+"_"+POST['postId']+POST['postExt'])
fileDir = directory / (
POST["postSubmitter"]+"_"+title+"_"+POST['postId']+POST['postExt']
)
tempDir = directory / (
POST["postSubmitter"]+"_"+title+"_"+POST['postId']+".tmp"
)
try:
getFile(fileDir,tempDir,POST['postURL'])
except FileNameTooLong:
fileDir = directory / (POST['postId']+POST['postExt'])
tempDir = directory / (POST['postId']+".tmp")
getFile(fileDir,tempDir,POST['postURL'])