XBMC Community Forum  

Go Back   XBMC Community Forum > Development > Plugin/Script (Python) Development

Plugin/Script (Python) Development Developers forum for XBMC Python Plugins/Scripts. Scripters/coders only!
Not for posting feature requests, bugs, or end-user support requests!

Reply
 
Thread Tools Search this Thread Display Modes
Old 2004-05-06, 15:25   #1
carlosp_uk
Member
 
Join Date: Apr 2004
Posts: 47
carlosp_uk is on a distinguished road
Default

hello

i have a central shared folder on my network which contains all the current tv listings in xmltv format. (thanks to the great xmltv software which grabs it off the net)

is there a way to read this file over the network within python, e.g:

xmldata = self.readfile("smb://userassword@computer/tv/listings.xml")

??

it doesn't seem to work, i get 'file not found'. (but i remember the author of the mythtv scripts saying that he had a workaround?) or could it be added into the current python implementation?

any help appreciated!


carlos




ps: currently, i get it to auto-ftp the listings to the xbox, but this is a hassle.
carlosp_uk is offline   Reply With Quote
Old 2004-05-06, 18:08   #2
bitplane
Member
 
Join Date: Mar 2004
Location: England
Posts: 76
bitplane is on a distinguished road
Default

i don't think there's a raw access to files over smb at the moment, you're probably best off using an ftp server on your pc and using python to download the file to your xbox, rather than uploading it to your xbox (if that's what you're doing)

python ftplib
__________________
bit's bits, snips and scripts
04h
bitplane is offline   Reply With Quote
Old 2004-05-06, 22:17   #3
carlosp_uk
Member
 
Join Date: Apr 2004
Posts: 47
carlosp_uk is on a distinguished road
Default

yeah, thanks for this, i guess so, if the ftp library is implemented in XBMC. but surely there must be a way to access remote files within python?

any developers care to comment, or have news on an implementation?
carlosp_uk is offline   Reply With Quote
Old 2004-05-07, 00:36   #4
dwe_3
Junior Member
 
Join Date: Apr 2004
Posts: 8
dwe_3 is on a distinguished road
Default

python has socket support so it should be fairly easy to write a script that accesses an xbms server (the protocol is fairly simple). smb on the other hand, i believe is complex although i have never bothered to look at what is known about it.

while on this topic, this is another reason i believe xbms (or another simple protocol) is more important to xbmc than smb support (that and the fact i don't want to run samba just for the xbox).
dwe_3 is offline   Reply With Quote
Old 2004-05-07, 10:04   #5
madtw
Senior Member
 
Join Date: Mar 2004
Posts: 174
madtw is on a distinguished road
Default

if you grab the xbmc mythtv source from http://changeling.ixionstudios.com/xbmc/,
you'll find smb.py and nmb.py in the python/lib directory. that is the library i am using to copy files from a smb share to the xbox. you can poke around the code to see how to use it. in particular, i just added smb.copytolocal() to copy a file from a remote share to the xbox file system. it should work fine for ascii files but at the moment seems to be broken for binary files.
madtw is offline   Reply With Quote
Old 2004-05-07, 10:41   #6
ent
Member
 
Join Date: Mar 2004
Posts: 74
ent is on a distinguished road
Default

i would definitely love to test your xmltv script carlos if you get it working, i had trouble displaying the results
ent is offline   Reply With Quote
Old 2004-05-07, 11:34   #7
carlosp_uk
Member
 
Join Date: Apr 2004
Posts: 47
carlosp_uk is on a distinguished road
Default

thanks for that guys - i'll have a look at your smb.py; that would be brilliant if it works.

i'll post the xmltv script up here when it's done - it's nothing special, i haven't used proper xml parsing yet as i couldnt get enough sample code of expat, so it's all r.e. matching. but it works!
carlosp_uk is offline   Reply With Quote
Old 2004-05-07, 12:23   #8
madtw
Senior Member
 
Join Date: Mar 2004
Posts: 174
madtw is on a distinguished road
Default

btw, you'll want to grab version 0.5. version 0.4 did not have the copytolocal() method.

edit: i have updated xbmc mythtv to version 0.6 that fixes binary file copies. you can call smb.copytolocal( remoteservice, remotepath, localpath ) to copy files from a smb share to the xbox filesystem.
madtw is offline   Reply With Quote
Old 2004-05-10, 20:31   #9
carlosp_uk
Member
 
Join Date: Apr 2004
Posts: 47
carlosp_uk is on a distinguished road
Default

madtw that's fantastic! thank you!

not sure on the syntax to use this. do you have an example function call for copytolocal ?

e.g. what if i want to copy
smb://domain;userassword@server/share/file.xml

do i do:
Quote:
copytolocal("server/share","file.xml","q:\\folder\\dest.xml")
...and then edit the rest of the function call to be
Quote:
def copytolocal(self, src_service, src_path, dest_path, callback = none, write_mode = smb_o_creat | smb_o_trunc, src_password = "password", dest_password = none, timeout = none):
....although i can't see where to put the username/domain, so is it:

Quote:
copytolocal("domain;username:pass@server/share","file.xml","q:\\folder\\dest.xml")
carlosp_uk is offline   Reply With Quote
Old 2004-05-12, 04:35   #10
madtw
Senior Member
 
Join Date: Mar 2004
Posts: 174
madtw is on a distinguished road
Default

your best bet is to look in mytvshow.py to see how to call copytolocal(). the short answer is that you must instantiate a smb object first and do the login, then you can issue a copytolocal() method call. this is what it would look like with no error handling:

Quote:
remote = smb.smb(host,hostip)
if remote.is_login_required():
remote.login( user, password, domain )

remotepath = "%s%s%s" % (dirpath,os.sep,filename)
remote.copytolocal( service, remotepath, localpath )
so host would be the "server" from your example. the service would be set to the "share". the rest of the fields should make sense.

btw, i found these nmb and smb modules on the web. since the copy() method assumed two remote smb shares, i added the copytolocal() method based on the code in the copy() method. i probably should've gotten rid of the rest of the parameters... but i wasn't sure what i was going to need until i got it working. once i got it working, i didn't go back to clean it up...
madtw is offline   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

Similar Threads
Thread Thread Starter Forum Replies Last Post
All files played from network, except for one punkinguk XBMC for Xbox Specific Support 2 2006-04-18 04:51
XBMC - files over network retepetsir XBMC for Xbox Specific Support 1 2006-02-08 14:27
Avi files won't play over network twentworth22 XBMC for Xbox Specific Support 0 2005-05-01 18:00
Xbmc can see wma files on the network but not dvd LostIt XBMC for Xbox Specific Support 1 2005-02-04 19:51
Python network problems back XBMC for Xbox Specific Support 0 2005-01-02 00:55


All times are GMT +2. The time now is 22:41.


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