v1.8.0 (#105)
## Change log - Youtube support added - Custom filenames feature added - Custom folder structure feature added - Unsaving downloaded posts option added - Remove duplicate posts on different subreddits option added - Skipping given domains option added - Keeping track of already downloaded posts on a separate file option added (See --dowloaded-posts in README) - No audio on v.redd.it videos bug fixed (see README for details about ffmpeg) - --default-directory option is added - --default-options is added - --use-local-config option is added - Bug fixes
This commit is contained in:
@@ -6,39 +6,24 @@ from bs4 import BeautifulSoup
|
||||
from src.downloaders.downloaderUtils import getFile, getExtension
|
||||
from src.errors import (FileNameTooLong, AlbumNotDownloadedCompletely,
|
||||
NotADownloadableLinkError, FileAlreadyExistsError)
|
||||
from src.utils import nameCorrector
|
||||
from src.utils import GLOBAL
|
||||
from src.utils import printToFile as print
|
||||
|
||||
class Redgifs:
|
||||
def __init__(self,directory,POST):
|
||||
try:
|
||||
POST['mediaURL'] = self.getLink(POST['postURL'])
|
||||
POST['MEDIAURL'] = self.getLink(POST['CONTENTURL'])
|
||||
except IndexError:
|
||||
raise NotADownloadableLinkError("Could not read the page source")
|
||||
|
||||
POST['postExt'] = getExtension(POST['mediaURL'])
|
||||
|
||||
POST['EXTENSION'] = getExtension(POST['MEDIAURL'])
|
||||
|
||||
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['mediaURL'])
|
||||
except FileNameTooLong:
|
||||
fileDir = directory / (POST['postId']+POST['postExt'])
|
||||
tempDir = directory / (POST['postId']+".tmp")
|
||||
|
||||
getFile(fileDir,tempDir,POST['mediaURL'])
|
||||
filename = GLOBAL.config['filename'].format(**POST)+POST["EXTENSION"]
|
||||
shortFilename = POST['POSTID']+POST['EXTENSION']
|
||||
|
||||
getFile(filename,shortFilename,directory,POST['MEDIAURL'])
|
||||
|
||||
def getLink(self, url):
|
||||
"""Extract direct link to the video from page's source
|
||||
|
||||
Reference in New Issue
Block a user