Reversed the episodes list order to match the loop count with the actual episode number.
This commit is contained in:
parent
14fc8c4a6f
commit
67c81ce499
1 changed files with 10 additions and 7 deletions
|
@ -50,6 +50,9 @@ for video in videos['items']:
|
||||||
video['snippet']['title'] + '\t' + video['snippet']['description'] + '\t'
|
video['snippet']['title'] + '\t' + video['snippet']['description'] + '\t'
|
||||||
+ 'http://youtube.com/watch?v=' + video['id']['videoId'])
|
+ 'http://youtube.com/watch?v=' + video['id']['videoId'])
|
||||||
|
|
||||||
|
# Reverse sort the episodes list
|
||||||
|
episodes.reverse()
|
||||||
|
|
||||||
# Let's go. The program will execute until run = False
|
# Let's go. The program will execute until run = False
|
||||||
run = True
|
run = True
|
||||||
while run:
|
while run:
|
||||||
|
@ -60,18 +63,18 @@ while run:
|
||||||
# Loop through and print the episodes list.
|
# Loop through and print the episodes list.
|
||||||
count = 0
|
count = 0
|
||||||
for episode in episodes:
|
for episode in episodes:
|
||||||
# Increment the loop count, same as: count = count + 1
|
|
||||||
count += 1
|
|
||||||
# Split the episode info using tab as the delimiter
|
# Split the episode info using tab as the delimiter
|
||||||
episodeInfo = episode.split('\t')
|
episodeInfo = episode.split('\t')
|
||||||
# Print the loop count & title
|
# Print the loop count & title
|
||||||
# The count is converted into a str, and right justified
|
# The count is converted into a str, and right justified
|
||||||
print ' {0}. {1}'.format(str(count).rjust(2), episodeInfo[0])
|
print ' {0}. {1}'.format(str(count).rjust(2), episodeInfo[0])
|
||||||
|
# Increment the loop count, same as: count = count + 1
|
||||||
|
count += 1
|
||||||
|
|
||||||
print
|
print
|
||||||
|
|
||||||
# Ask for the episode number
|
# Ask for the episode number
|
||||||
choice = raw_input('Enter 1-' + str(count) + ' (or ENTER to quit): ')
|
choice = raw_input('Enter 0-' + str(count) + ' (or ENTER to quit): ')
|
||||||
|
|
||||||
# Did you press enter?
|
# Did you press enter?
|
||||||
if not choice:
|
if not choice:
|
||||||
|
@ -84,13 +87,13 @@ while run:
|
||||||
selection = int(choice)
|
selection = int(choice)
|
||||||
|
|
||||||
# It must also be between 1 and the total number of episodes
|
# It must also be between 1 and the total number of episodes
|
||||||
# Could be written as: selection >= 1 and selection <= count
|
# Could be written as: selection >= 0 and selection <= count
|
||||||
if 1 <= selection <= count:
|
if 0 <= selection <= count:
|
||||||
print
|
print
|
||||||
print
|
print
|
||||||
print '=============================================================================='
|
print '=============================================================================='
|
||||||
# Split the selected episode info using tab as the delimiter, the list is zero-based
|
# Split the selected episode info using tab as the delimiter
|
||||||
episodeInfo = episodes[selection - 1].split('\t')
|
episodeInfo = episodes[selection].split('\t')
|
||||||
# Print the episode title
|
# Print the episode title
|
||||||
print episodeInfo[0]
|
print episodeInfo[0]
|
||||||
print
|
print
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue