Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6768997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:08:26+00:00 2026-05-26T15:08:26+00:00

I am writing a simple script to download .mp4 TEDTalks given a list of

  • 0

I am writing a simple script to download .mp4 TEDTalks given a list of TEDTalk website links:

# Run through a list of TEDTalk website links and download each
# TEDTalk in high quality MP4

import urllib.request

#List of website links
l = [
        "http://www.ted.com/index.php/talks/view/id/28",
        "http://www.ted.com/index.php/talks/view/id/29",
    ]

# Function which takes the location of the string "-480p.mp4",
# d = 1 less that location, and a string and returns the
# full movie download link
def findFullURL(d, e, s):
    a = s[d]
    if a != "/":
        #Subtract from d to move back another letter
        d = d - 1
        findFullURL(d, e, s)
    else:
        fullURL = "http://download.ted.com/talks/" + s[(d+1):e] + "-480p.mp4"
        #print(fullURL)
        return fullURL

#Iterate through a list of links to download each movie
def iterateList(l):
    for x in l:
        #get the HTML
        f = urllib.request.urlopen(x)
        #Convert the HTML file into a string
        s = str(f.read(), "utf-8")
        f.close()
        #Find the location in the string where the interesting bit ends
        e = s.find("-480p.mp4")
        d = e - 1
        #The problem is with this variable url:
        url = findFullURL(d, e, s)
        print("Downloading " + url)
        #TODO: Download the file

I am certain that the function findFullURL works. If you uncomment the print(fullURL) line at the end of the findFullURL function, you will see it output the download link exactly as I need it.

However, in the iterateList function where I try to capture that string via url = findFullURL(d, e, s), the variable url seems to take on the value None. I do not understand this at all. It should be as simple as the following example, which works when I try it in the interpreter:

def hello():
    return "Hello"
url = hello()
print(url)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:08:26+00:00Added an answer on May 26, 2026 at 3:08 pm

    I am certain that the function findFullURL works.

    Being certain that a certain piece of code works is the best way to waste hours of debugging time looking in the wrong place.

    In fact that function does not work. You are missing a return:

    def findFullURL(d, e, s):
        a = s[d]
        if a != "/":
            #Subtract from d to move back another letter
            d = d - 1
            return findFullURL(d, e, s)   # <<<<<<< here
        else:
            fullURL = "http://download.ted.com/talks/" + s[(d+1):e] + "-480p.mp4"
            #print(fullURL)
            return fullURL
    

    Also, you shouldn’t be using recursion to solve this task. You can use rfind instead.

    def findFullURL(d, e, s):
        d = s.rfind('/', 0, d + 1)
        # You probably want to handle the condition where '/' is not found here.
        return "http://download.ted.com/talks/" + s[(d+1):e] + "-480p.mp4"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a very simple Bash script that tars a given directory, encrypts
I'm writing a simple Perl script (on Windows) to download the response of a
I'm writing a simple script, that just connects to telnet port, listens everything on
I am writing a simple GreaseMonkey script that has a jQuery plugin called hoverIntent
I'm writing a simple Greasemonkey script to strip out all the images, headings and
I am writing a simple Python script with no GUI. I want to be
I'm currently writing a simple .sh script to parse an Exim log file for
I am writing a simple unix shell script: #!/bin/bash # abort the script if
I'm writing a PHP script and the script outputs a simple text file log
at the moment I'm writing a simple script in ksh who should take some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.