def addPodcast(url): name = fileUtil.getPodcastName(url) #Gets the name of the podcast if (name == None): #Checks if it has found no name print("Error - There has been an issue getting the podcasts name...\n" ) #If so this is an error return name = fileUtil.cleanForWindows(name) #Removes invalid characters file = open(".feeds", 'a') file.writelines(url + "," + name + "\n") file.close
def updatePodcastXML(url): #First get the podcasts name name = fileUtil.getPodcastName(url) #Gets the name from the url if (name == None): #Checks if it has found no name print("Error - Podcast has no name...") #If so this is an error return name = fileUtil.cleanForWindows( name) #Removes any characters from a name that are invalid in linux #Downloading the rss file rssFilepath = Path(".rss/" + name) print("\nDownloading rss file for: " + name) success = webUtil.downloadFileStream(url, rssFilepath, 0) #Downloads the rss file if (success == False): print("Error in updating podcast") return else: print("Checking for new episodes") urls = fileUtil.getEnclosedLinks( str(rssFilepath)) #Gets the enclosed links and titles from the file #Check for a folder podcastFolderExists = fileUtil.checkDir(name) if (not (podcastFolderExists)): os.mkdir(name) #Run the urls (episodes) for url in urls: filePathSansType = Path( name + "/" + url[0]) #Generates the filepath for where the new file will go fileAlreadyExists = fileUtil.checkFileSansType( filePathSansType) #Checks to see if the file is already downloaded if (not (fileAlreadyExists)): #If not filetype = webUtil.getFileType( url[1]) #Gets the filetype of the file the url points to if (filetype == None): #If the filetypes is not found correctly print("Error Downloading file") #Error message continue #Try next file filePath = Path( name + "/" + url[0] + filetype ) #Create the filepath where the file will be downloaded to print("Fetching new file: " + url[0]) success = webUtil.downloadFileStream( url[1], filePath, 0) #Download the file to the correct location if (success == None): print("Error - File not downloaded")