TITLE: Updating pypodd to download most recent
DATE: 2018-06-25
AUTHOR: John L. Godlee
====================================================================


Pypodd

I've been working a bit more on Pypodd recently, cleaning up the
code a bit and making it slightly more user friendly.

One thing I did was to include an option at the start of the
program which allows you to choose to download the most recent
episode of each podcast. This is the snippet of the code which lets
you do that, mostly using feedparser to compile lists of RSS feeds
and extract the important bits of information:

   while input_exit != 2:  # Terminate program if input_exit == 2
       count_opt = 1
       optListAllNo = ['All most recent episodes', 'Specific
episode']  # A list of options
       for i in optListAllNo:
           print(str(count_opt) + ") " + i)
           count_opt += 1
       input_all_no = input("\nChoose an option: ")
       input_all_no = int(input_all_no)
       if input_all_no == 1:
           feedList = []  # Create empty list
           for i in urlList:  # Put the parsed feeds in the list
               parseBar = Bar("Parsing feeds", max = len(subList))
               feedList.append(feedparser.parse(i))
               parseBar.next()
           parseBar.finish()
           ep0List = []  # Create empty lists
           name0List = []
           link0List = []
           for i in feedList:  # Extract most recent episode from
each feed
               ep0List.append(i['entries'][0])
           for i in ep0List:
               link0List.append(i['enclosures'][0]['href'])  #
Extract download URL from list
               name0List.append(i['title'])  # Extract episode
name from list
           print("\n Downloading all most recent episodes")

           dlExt = ".mp3"
           for i, j in zip(link0List, name0List):  # Download most
recent episode and give names
                   dlName = j.replace("/", "_")
                   dlFile = destDir + dlName + dlExt
                   dlURL = i
                   dlProg().get(dlURL, dlFile)
           print("\nFinished, exiting")  # Exit

           input_exit = 2
       elif input_all_no == 2:
   ...  # Code continues with other options below

I'm still hoping that at some point in the future I can implement a
databse style structure which says which episodes have been
downloaded already and flags them on the list of available episodes.

I'm also having trouble in that some of the progress bars replicate
if they are too long for the line. This doesn't affect the function
of the program at all, but it does make it look really messy.