Sunday, November 17, 2024
Google search engine
HomeLanguagesPython IMDbPY – Getting Series Run times as XML

Python IMDbPY – Getting Series Run times as XML

In this article we will see how we can get the series run times information(info-set) in the XML format. Extensible Markup Language (XML) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. Series object contains all the information about all the episodes and seasons that has records at IMDb data base. Run times are basically the times series had run.

In order to get this we have to do the following 1. Import the IMDbPY module 2. Create a instance of IMDB 3. Get the series object with the help of series ID 4. Get the XML format value here it will be in string by converting the series object into XML with the help of ‘runtimes’ keyword

Below is the implementation 

Python3




# importing the module
import imdb
  
# creating instance of IMDb
ia = imdb.IMDb()
  
# id
code = "6077448"
   
# getting information
series = ia.get_movie(code)
   
# printing title
print(series.data['title'])
 
print("--------------------------------")
 
# converting series object's RUN TIMES into XML file
xml = series.getAsXML('runtimes')
 
# printing the XML file
print(xml)


Output :

Sacred Games
--------------------------------
<runtimes infoset="main"<item50</item</runtimes

Another example 

Python3




# importing the module
import imdb
  
# creating instance of IMDb
ia = imdb.IMDb()
  
# id
code = "6468322"
   
# getting information
series = ia.get_movie(code)
   
# printing title
print(series.data['title'])
 
print("--------------------------------")
 
# converting series object's RUN TIMES into XML file
xml = series.getAsXML('runtimes')
 
# printing the XML file
print(xml)


Output :

Money Heist
--------------------------------
<runtimes infoset="main"<item 70</item</runtimes

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments