Unrar - documentation?

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Popeye Offline
Posting Freak
Posts: 875
Joined: Aug 2009
Reputation: 25
Location: Sweden
Post: #1
I'm having a hard time finding documentation for XBMC especially concerning the built in unrar functions and what can be done in python. Could be me looking in the wrong places but most documents seems to be from 2007-ish..
Anyhow, I have looked at
Code:
xbmc.executebuiltin( "XBMC.extract(file,dest)"
I have also looked att rarfile.py
Then I have also found the notification "rar://...." but no info on how to use this..

Im looking for a way to list contents and extract from small rar files.

So any pointers on what is the "correct" solution?

sverigesradio | Pneumatic | SABnzbd | XBMC that just works - openelec
find quote
MDPauley Offline
Senior Member
Posts: 264
Joined: Mar 2004
Reputation: 0
Location: Centreville, Va
Post: #2
Popeye Wrote:So any pointers on what is the "correct" solution?

What is the exact line you tried to use. Post the whole script/plugin on pastebin if possible.
find quote
Popeye Offline
Posting Freak
Posts: 875
Joined: Aug 2009
Reputation: 25
Location: Sweden
Post: #3
Sorry but I dont have. I have managed to list files using rarfile.py but Im looking for some sort of documentation/description on how to use the other features and a developers point of view what is the best solution for listing and unpacking rar's.
I read that xbmc.executebuiltin( "XBMC.extract(file,dest)" requires absolute paths but Im unsure about the limitations of this and somewhere in the source code there is some mentioning of allowing "special://.." ..
Also the "rar://.." notation is afaik lacking documentation (or, most probably, I'm just blind Smile )

sverigesradio | Pneumatic | SABnzbd | XBMC that just works - openelec
find quote
spiff Offline
Grumpy Bastard Developer
Posts: 12,185
Joined: Nov 2003
Reputation: 82
Post: #4
rar://<urlencodedpathtoarchive>/<fileinarchive> - though extract would be of the form

executebuiltin('extract(/path/to/archive.rar,/path/to/extract)') - no rar:// urls involved.

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
find quote
Popeye Offline
Posting Freak
Posts: 875
Joined: Aug 2009
Reputation: 25
Location: Sweden
Post: #5
@Spiff, thanks for the info
I haven tried but should this work (I'm at work..)?
Code:
import os
path="rar://path/to/my.rar"  
dirList=os.listdir(path)
for fname in dirList:
    print fname
f = open(dirList[0])
text = f.read()
f.close()
fOut = open("/some/other/file.txt", 'w')
fOut.write(text)
fOut.close()

sverigesradio | Pneumatic | SABnzbd | XBMC that just works - openelec
(This post was last modified: 2010-01-19 16:49 by Popeye.)
find quote
spiff Offline
Grumpy Bastard Developer
Posts: 12,185
Joined: Nov 2003
Reputation: 82
Post: #6
no. i said url encoded. and keep the trailing /

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
find quote
LtChambers Offline
Junior Member
Posts: 33
Joined: Dec 2009
Reputation: 1
Post: #7
Not a chance (you're calling the os module's listdir function, which has nothing to do with XBMC). If you want the file list of a RAR with a pure python application you'll have to use rarfile.py.
find quote
Popeye Offline
Posting Freak
Posts: 875
Joined: Aug 2009
Reputation: 25
Location: Sweden
Post: #8
spiff Wrote:no. i said url encoded. and keep the trailing /

LtChambers Wrote:Not a chance (you're calling the os module's listdir function, which has nothing to do with XBMC). If you want the file list of a RAR with a pure python application you'll have to use rarfile.py.

Suspected this. Thank you! Will stick with rarfile.py then..

sverigesradio | Pneumatic | SABnzbd | XBMC that just works - openelec
find quote
Popeye Offline
Posting Freak
Posts: 875
Joined: Aug 2009
Reputation: 25
Location: Sweden
Post: #9
Finally found a solution...
Code:
filePath = xbmc.translatePath(( os.path.join( "special://temp/", fileName ) ))
#Prepare a dir to extract to
extractPath = xbmc.translatePath("special://temp/" + fileName + ".out")
xbmc.executebuiltin("XBMC.Extract("+filePath+","+extractPath+")")

sverigesradio | Pneumatic | SABnzbd | XBMC that just works - openelec
find quote
Popeye Offline
Posting Freak
Posts: 875
Joined: Aug 2009
Reputation: 25
Location: Sweden
Post: #10
Got a minor issue. If I execute
Code:
xbmc.executebuiltin("XBMC.Extract("+filePath+","+extractPath+")")
#time.sleep(2)
pattern = "*.srt"
files = os.listdir(extractPath)
for filename in fnmatch.filter(files, pattern):
    subtitle = filename
    print subtitle

I find nothing, but adding "time.sleep(2)" after the extraction lists the files.

Thus I need some way of making sure the extraction is finnished. What is the best way to catch the return code?

sverigesradio | Pneumatic | SABnzbd | XBMC that just works - openelec
find quote
Post Reply