XBMC Community Forum  

Go Back   XBMC Community Forum > Help and Support > Plugin/Script (Python) Help and Support

Plugin/Script (Python) Help and Support Python requests/suggestions, support, bugs, and everything python goes in here!
Please, add platform prefix to threads that are not platform-independent!:
Thread prefixes; "[LINUX]", "[LIVE]", "[MAC]", "[WINDOWS]", and "[XBOX]"

Reply
 
Thread Tools Search this Thread Display Modes
Old 2004-11-07, 12:10   #1
rupert05
Junior Member
 
Join Date: Nov 2004
Posts: 4
rupert05 is on a distinguished road
Thumbs up

hi,
i am a total newbie to python but i have an idea.
i use this to organize my dvd movies:
phpvideodb

i created a xml file which contains information about the movies, taken from the database and converted to xml using perl.
it looks like this:

Quote:
<row>
<title>barfly</title>
<language>english</language>
<year>1987</year>
<imgurl>http://ia.imdb.com/media/imdb/01/i/44/72/80m.jpg</imgurl>
//some other lines go here
</row>
now is there a way to write a python script that creates from this information a listing?
i looked at some rss news scripts to understand hot it works,
but often they are to specific to use them for my needs.
the xml file can be accessed through a local apache server or simply copied to the xbox.

if someone can give me some hints or has free time to set up an initial code, i would do my best to help and finish the script to perfection.

thx
rupert04
rupert05 is offline   Reply With Quote
Old 2004-11-07, 18:55   #2
solexalex
Skilled Python Coder
 
Join Date: Jul 2004
Posts: 550
solexalex is on a distinguished road
Default

python can easily parse your xml and do whatever you want with all the informations.
it will download the xml, then read it to extract all the tags.

i am too much a beginner, and i don't know anything with xml... but many many existing scripts are doing like this
solexalex is offline   Reply With Quote
Old 2004-11-14, 18:35   #3
rupert05
Junior Member
 
Join Date: Nov 2004
Posts: 4
rupert05 is on a distinguished road
Default

no one?
it couldn't be that uninterresting, only thing is that many people dont have a apache or something else running.
but from my knowledge many other media(movie, music) databases tools have a export function, maybe there is a way to make this thing multi backend able.
i wish i could start python, but atm i have to learn java for school.
rupert05 is offline   Reply With Quote
Old 2004-11-16, 04:22   #4
solexalex
Skilled Python Coder
 
Join Date: Jul 2004
Posts: 550
solexalex is on a distinguished road
Default

sorry, but you answered like if you didn't see my answer....
solexalex is offline   Reply With Quote
Old 2004-11-16, 09:12   #5
rupert05
Junior Member
 
Join Date: Nov 2004
Posts: 4
rupert05 is on a distinguished road
Default

oh, i read it.
can you point me to some scripts that can be converted,
the ones i tried where to special.
rupert05 is offline   Reply With Quote
Old 2004-11-18, 02:24   #6
solexalex
Skilled Python Coder
 
Join Date: Jul 2004
Posts: 550
solexalex is on a distinguished road
Default

the script that use the most xml i think is named kml browser.
i don't know yet how to use dom.minidom xml parser. but i need to learn.
solexalex is offline   Reply With Quote
Old 2004-11-25, 21:51   #7
afeno
Junior Member
 
Join Date: Oct 2004
Location: Barcelona
Posts: 28
afeno is on a distinguished road
Default

hi there,
i have done this two weeks ago with my movies db. now i can see my movie db using the xbmc. and with the posters *of the movies!

i have my movies db in a apache web server and i use this php program to manage the db: modified version of php4flicks version 0.33.4
this php script can retrieve all the information from imdb inclued the poster of the moive similar to phpvideodb.


this is my web movies db: http://www.afeno.no-ip.com/pelisdb/index4.php

and this is the xml that it's automatically created using a php that i mafe to have the hole list of the movies:
http://www.afeno.no-ip.com/pelisdb/print/listxml.xml

then, my phyton scrip access to this xml and generate the list. it also download the poster and save them in the hd the first time that you check one movie.

this script was designed to work with this xml design, but you can adapt it to your xml format.

here you are phytom script that i created:
http://www.afeno.no-ip.com/mymovies.py
screenshot:
http://www.afeno.no-ip.com/screenshot.jpg

i have to say that i'm a beginner. i just used some others scripts to understand how does it works...

now, i'm trying to check the imdb information directly throw the phytom script. does anyone know if i can call to some function/procedure from phytom to access to the imdb information for a movie?


saludos.
alfredo.
afeno is offline   Reply With Quote
Old 2004-11-25, 22:05   #8
rupert05
Junior Member
 
Join Date: Nov 2004
Posts: 4
rupert05 is on a distinguished road
Default

sounds very good,
i will check your scripts out when they arrive.
--
it dont really understand how the xml file gets parsed,
i think its this lines:
Quote:
for item in items:
peli = str(item.childnodes[3].childnodes[0].nodevalue)
dura = str(item.childnodes[7].childnodes[0].nodevalue)
medias = str(item.childnodes[1].childnodes[0].nodevalue)
id = str(item.childnodes[11].childnodes[0].nodevalue)

self.posters.append(id)

game = medias+"-> "+peli+" ("+dura+" min)"
what do i have to change that my xml style gets parsed?
peli is the title, right?
is that spain?
rupert05 is offline   Reply With Quote
Old 2004-11-26, 22:39   #9
afeno
Junior Member
 
Join Date: Oct 2004
Location: Barcelona
Posts: 28
afeno is on a distinguished road
Default

hi,
in my case, the xml file has this format:

Quote:
*<item>
*<nr>d028</nr>
*<name>before sunset</name>
*<lang>en</lang>
*<runtime>80</runtime>
*<medium>divx/xvid</medium>
*<id>381681</id>
*</item>
and the way that i access the data from the xml that i want is:

item.childnodes[1].childnodes[0].nodevalue -> is d028 (dvd number)
item.childnodes[3].childnodes[0].nodevalue -> before sunset (movie name)
item.childnodes[5].childnodes[0].nodevalue -> en (language)
item.childnodes[7].childnodes[0].nodevalue -> 80 (time)
item.childnodes[9].childnodes[0].nodevalue -> divx/xvid (type of avi)
item.childnodes[11].childnodes[0].nodevalue -> 381681 (imdb movie id)

and then i creat the row to add in the list:
game = medias+"-> *"+peli+" * ("+dura+" min)"

d028-> *before sunset (80 min)

and i do this for each item (movie)

Quote:
for item in items:
peli = str(item.childnodes[3].childnodes[0].nodevalue)
dura = str(item.childnodes[7].childnodes[0].nodevalue)
medias = str(item.childnodes[1].childnodes[0].nodevalue)
id = str(item.childnodes[11].childnodes[0].nodevalue)

self.posters.append(id)

game = medias+"-> *"+peli+" * ("+dura+" min)"
Quote:
what do i have to change that my xml style gets parsed?
1) first, made the necessary changes to get the movie list working.
2) then you have to modify the code to get the posters properly.


1) you have to change this part of the code in order to get all the movies properly:

source:
for node in dados.documentelement.childnodes:
if (node.nodename == "item"):
items.append(node)

changed:
for node in dados.documentelement.childnodes:
if (node.nodename == "row"):
items.append(node)

source:


for item in items:
peli = str(item.childnodes[3].childnodes[0].nodevalue)
dura = str(item.childnodes[7].childnodes[0].nodevalue)
medias = str(item.childnodes[1].childnodes[0].nodevalue)
id = str(item.childnodes[11].childnodes[0].nodevalue)

self.posters.append(id)

game = medias+"-> *"+peli+" * ("+dura+" min)"

changed *for your xml:

for item in items:
title= str(item.childnodes[1].childnodes[0].nodevalue)
lang = str(item.childnodes[3].childnodes[0].nodevalue)
year= str(item.childnodes[5].childnodes[0].nodevalue)
image = str(item.childnodes[7].childnodes[0].nodevalue)

self.posters.append(image)

game = year+" *"+title+" * ("+lang+")"

2) now, you have to change the 'poster()' function:
(all the posters are stored in the 'posters' array)

source:
def poster(self,post):
bg2 = downloadimage2('http://'+dirip+'/pelisdb/imgget.php?for='+self.posters[post],self.posters[post]+".jpg")
self.addcontrol(xbmcgui.controlimage(580,50,97,150 , bg2))

changed for your xml:
def poster(self,post):
bg2 = downloadimage2(self.posters[post],imgname(self.posters[post]))
self.addcontrol(xbmcgui.controlimage(580,50,97,150 , bg2))

and in your case you have to create a new function 'imgname':
imgname (url):string

that takes as argument the url and return the a name of the image. you only have to ensure that it generate a different name of different urls but it have to generate the same name for the same url... or something like this:
imgname(http://ia.imdb.com/media/imdb/01/i/44/72/80m.jpg)=
01i447280m.jpg

please, take in mind that the 'changed for your xml' code is just a suggestion but i didn't try it and may be it doesn't work or may be it has syntax errors. it's just the idea.


Quote:
peli is the title, right?
yes, peli is the title of the movie.
Quote:
is that spain?
yes, it's spanish.

good luck!
if you have any doubt just let me know.
i hope that i can help you, but i'm not use to program in phytom....

best regards.
alfredo fenoglio
afeno is offline   Reply With Quote
Old 2004-12-08, 21:47   #10
mr_pink
Guest
 
Posts: n/a
Thumbs up

hi guys...
interesting topic i think ! but the most interesting thing isn´t said there. did anyone manage to solve the issue to convert his data to the xbmc - for example as mentioned as a python solution.
i´m very interested in this topic and if anyone has brought this topice any further plz post it in here. i think a proper solution is a great for all of us thinking of doing something like that.

i´m interested in everything beginning from what software are you using for webserver/php/perl/python to the scripts themselves.

plz email me instantly :thumbsup:

thank you very much for your work !
  Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 20:48.


Protected by Akismet, We recommend WordPress blogs
Copyright © 2008, XBMC Project