Introducing an Open Source Indian TV Schedule API

For this semester's project I required an open source API, that gives a schedule of channel of particular date. I found an API, but it wasn't open source. Then after some googeling and wasting my time, I knew I will have to write one. So I started writing it. so now if you need API for same purpose you don't need to write new. And if this project doesn't satisfy your requirement you can read the source code to understand process and write your own.

This API is written in Python. You can use it by command line interface or you can run as local server and send it HTTP requests. I have deployed app on Google's app engine on free quota, so it may not be running at the time you want it, though you can try it here.

Download script from github.

Below I will only explain server version and not cli. you can use python3 main.py --help for help using cli.

  1. start server using  --server flag. Use --port parameter for custom port. App will run on port 8080 by default. python3 main.py --server --port 8000
  2. Now local server is running on port 8000. All you need to do is send HTTP request and retrive json data

HTTP Request Parameters

  • channel This is required parameter. The value of this parameter is name of channel. replace space in the name of channel with hyphen(-). e.g. 'Star Movies' will become 'star-movies'. to get list of available channels use cli program. or view it on indian-tv-schedule-api.appspot.com e.g.
    GET /?channel='star-movies' HTTP/1.0 Example:
    localhost:8000?channel=star-movies
    Output:
    
    {
        "channel": "star-movies", 
        "date": "2015-03-13", 
        "shows": [
            {
                "showThumb": "http://tvimages.burrp.com/images/s/d/x/dxah331i_33kf_1_75.jpg", 
                "showTime": "19:08", 
                "showTitle": "R.I.P.D."
            }, 
            {
                "showThumb": "http://tvimages.burrp.com/images/s/1/8/18ybcu1i_347h_1_75.jpg", 
                "showTime": "20:59", 
                "showTitle": "Curse of Chucky"
            }, 
            {
                "showThumb": "http://tvimages.burrp.com/images/s/f/l/flv7fsth_2wle_1_75.jpg", 
                "showTime": "22:55", 
                "showTitle": "American Pie 2"
            }
        ]
    }
    
    
  • dateUse this argument to specify the date of which you want to retrieve schedule. use YYYY-MM-DD format. If you don't give this argument, today's date will be taken. Invalid date format will result into error.
    GET /?channel=star-movies&date=2015-03-15 HTTP/1.0 Example.
    localhost:8000?channel=star-movies&date=2015-03-15
    Output.
    
    {
        "channel": "star-movies", 
        "date": "2015-03-15", 
        "shows": [
            {
                "showThumb": "http://tvimages.burrp.com/images/s/r/u/ruru7h3i_35td_1_75.jpg", 
                "showTime": "01:14", 
                "showTitle": "My Lucky Stars"
            }, 
            {
                "showThumb": "http://tvimages.burrp.com/images/s/e/i/eims7nmh_1fwv_1_75.jpg", 
                "showTime": "02:43", 
                "showTitle": "Fillers"
            }, 
            {
                "showThumb": "http://tvimages.burrp.com/images/s/20150310/Shaolin_1425982770_75.jpg", 
                "showTime": "04:07", 
                "showTitle": "Shaolin"
            }, 
            {
                "showThumb": "http://tvimages.burrp.com/images/s/5/z/5zpmnv2i_355g_1_75.jpg", 
                "showTime": "06:09", 
                "showTitle": "Master With Cracked Fingers"
            }, 
            {
                "showThumb": "http://tvimages.burrp.com/images/s/9/p/9pbm2pzf_glh_1_75.jpg", 
                "showTime": "07:24", 
                "showTitle": "Aladdin"
            }, 
            {
                "showThumb": "http://tvimages.burrp.com/images/s/u/u/uu7eyw2i_356j_1_75.jpg", 
                "showTime": "09:15", 
                "showTitle": "Paul"
            }, 
            {
                "showThumb": "http://tvimages.burrp.com/images/s/4/9/49hnmvhh_15ap_1_75.jpg", 
                "showTime": "11:27", 
                "showTitle": "Ice Age: The Meltdown"
            }, 
            {
                "showThumb": "http://tvimages.burrp.com/images/s/6/7/67o2deih_27em_1_75.jpg", 
                "showTime": "13:15", 
                "showTitle": "Rise of the Planet of the Apes"
            }, 
            {
                "showThumb": "http://tvimages.burrp.com/images/s/f/k/fk59v9cf_qy_1_75.jpg", 
                "showTime": "15:19", 
                "showTitle": "Anaconda"
            }, 
            {
                "showThumb": "http://tvimages.burrp.com/images/s/a/y/ays5d7ig_14uv_1_75.jpg", 
                "showTime": "17:07", 
                "showTitle": "Anacondas: Trail of Blood"
            }, 
            {
                "showThumb": "http://tvimages.burrp.com/images/s/i/l/il0bv9cf_r5_1_75.jpg", 
                "showTime": "19:02", 
                "showTitle": "Anacondas: The Hunt for the Blood Orchid"
            }, 
            {
                "showThumb": "http://tvimages.burrp.com/images/s/g/f/gf9mwduh_pr_8_75.jpg", 
                "showTime": "21:00", 
                "showTitle": "The Lost World: Jurassic Park"
            }, 
            {
                "showThumb": "http://tvimages.burrp.com/images/s/6/1/6107rjth_h9_4_75.jpg", 
                "showTime": "23:35", 
                "showTitle": "13 Ghosts"
            }
        ]
    }
    
    
  • meta Use this argument to include extra information (genre, language and showType) in each show detail. use True. don't use this argument at all if you don't want to retrive additional details, because meta=False won't work. GET /?channel=star-movies HTTP/1.0 Example.
    localhost:8000?channel=star-movies&meta=True
    Output.
    
    /* ... data ... */
      {
       "genre": "Action/Adventure,Comedy", 
       "language": "English", 
       "showThumb": "http://tvimages.burrp.com/images/s/d/x/dxah331i_33kf_1_75.jpg", 
       "showTime": "19:08", 
       "showTitle": "R.I.P.D.", 
       "showType": "Movie"
      }
    /* ... data ...*/
    
    
  • details same as above. except this will add yet another details like actors, director etc etc. GET /?channel=star-movies&detail=True HTTP/1.1 Example.
    localhost:8000?channel=star-movies&meta=True
    Output.
    
    /* ... data ... */
    {
       "actor": "Fiona Dourif, Danielle Bisutti, Brennan Elliott, Maitland McConnell, Chantal Quesnel, Summer H. Howell", 
       "alsoKnownAs": "Child’s Play 6 (USA)", 
       "director": "Don Mancini", 
       "imdbRating": "5.6/10", 
       "musicDirector": "Joseph LoDuca", 
       "producer": "David Kirschner, Don Mancini", 
       "releaseDate": "24 September 2013 (USA)", 
       "showDescription": "No information available!", 
       "showThumb": "http://tvimages.burrp.com/images/s/1/8/18ybcu1i_347h_1_75.jpg", 
       "showTime": "20:59", 
       "showTitle": "Curse of Chucky", 
       "trivia": "The actress who plays Nica, Fiona Dourif is the real life daughter of Brad Dourif, who provides the voice of Chucky.", 
       "writer": "Don Mancini"
      }
    /* ... data ...*/
    
  • indent Use this value if you want to prettify the output. positive integer tells the no. of tabs. -1 tells to compress the output. Example.
    localhost:8000/?channel=star-movies&indent=-1
    Output.
    
    {"channel": "star-movies", "date": "2015-03-13", "shows": [{"showThumb": "http://tvimages.burrp.com/images/s/d/x/dxah331i_33kf_1_75.jpg", "showTime": "19:08", "showTitle": "R.I.P.D."}, {"showThumb": "http://tvimages.burrp.com/images/s/1/8/18ybcu1i_347h_1_75.jpg", "showTime": "20:59", "showTitle": "Curse of Chucky"}, {"showThumb": "http://tvimages.burrp.com/images/s/f/l/flv7fsth_2wle_1_75.jpg", "showTime": "22:55", "showTitle": "American Pie 2"}]}
    
I hope this api works for you. If you need any help, any feature or complaint comment below. If any bug found please contact me. You can comment it also.

Hello World


Resources used:
Nicetranslator
BeautifulSoup
Python3
 
Wordle