Remember last folder?

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
mat_oli Offline
Junior Member
Posts: 20
Joined: Jun 2011
Reputation: 0
Post: #11
Sorry, just looked back at my code and realized I'd taken the "page" coding of it out because it wasn't really working for me at the time, but forgot to take out all references to it. You can take out all references to currentpage and intcurpg, or you can try the below code (I've left everything in there so this should definitely be working):

Code:
import xbmc
import os

line = ""
logfile = "C:\\XBMC.LST"
pagefile = "C:\\PAGE.LST"
posnfile = "C:\\POSN.LST"
lastpath = "Files"
readcount = 0

print "AUTOEXEC: CHECKING FILE"
if os.path.isfile(logfile) == True:
    print "AUTOEXEC: RESTORING PATH"    
    LF = open(logfile, 'r')
    for line in LF:
      print(line[:-1])
    LF.close()

    PGF = open(pagefile, 'r')
    currentpage = PGF.read()
    PGF.close()

    POSF = open(posnfile, 'r')
    position = POSF.read()
    POSF.close()
    
if (line<>""):
    lastpath = line

print "AUTOEXEC: LAST PATH="+lastpath
xbmc.executebuiltin('ActivateWindow(Videos,"'+lastpath+'")')

xbmc.sleep(5000)
#print "AUTOEXEC: Advancing to page: "+currentpage
#intcurpg = int(currentpage)
#print "AUTOEXEC: int value is: "+str(intcurpg)

#for i in range(intcurpg):
    #xbmc.executebuiltin('Action(pagedown)')
    #xbmc.executebuiltin('PageDown')

print "AUTOEXEC: Advancing to posn: "+position
intposn = int(position)
for i in range(intposn):
    print "AUTOEXEC: Moving down i: "+str(i)
    #xbmc.executebuiltin('Action(scrolldown)')
    xbmc.executebuiltin('Action(down)')
    #xbmc.executebuiltin('Down')
    
#xbmc.executebuiltin('Action(select)')
xbmc.executebuiltin('Action(highlight)')

count = 0
while (not xbmc.abortRequested):
    xbmc.sleep(30000)
    count = count + 1
    #print 'The count is:', count
    path = xbmc.getInfoLabel('Container.FolderPath')
    if (path<>"" ):
        lastpath = path
        LF = open(logfile, 'w')
        LF.write(lastpath)
        LF.close()
    
    currentpage = xbmc.getInfoLabel('Container.CurrentPage')
    if (currentpage<>"" ):
        PGF = open(pagefile, 'w')
        PGF.write(currentpage)
        PGF.close()
    
    #position = xbmc.getInfoLabel('Container.Position')
    position = xbmc.getInfoLabel('ListItem.Episode')
    if (position<>"" ):
        POSF = open(posnfile, 'w')
        POSF.write(position)
        POSF.close()
print "AUTOEXEC: FINISHED"
(This post was last modified: 2012-08-06 14:16 by mat_oli.)
find quote
djengomac Offline
Junior Member
Posts: 11
Joined: Jul 2012
Reputation: 0
Post: #12
Same issue, just a different NameError:
Code:
ERROR: Error Type: exceptions.NameError
ERROR: Error Contents: name 'position' is not defined
print "AUTOEXEC: Advancing to posn: "+position
NameError: name 'position' is not defined
find quote
mat_oli Offline
Junior Member
Posts: 20
Joined: Jun 2011
Reputation: 0
Post: #13
Just create a couple of dummy files with dummy values in them first so that the program has something to read from when attempting to read those values.
find quote
djengomac Offline
Junior Member
Posts: 11
Joined: Jul 2012
Reputation: 0
Post: #14
Sorry I'm a novice when it comes to this. What do you mean by dummy files with dummy values?
find quote
argh! Offline
Fan
Posts: 322
Joined: Jun 2011
Reputation: 0
Post: #15
Too lazy to ty it out, but it would certainly make an awesome addon. I've often had the desire for such a feature.
find quote
djengomac Offline
Junior Member
Posts: 11
Joined: Jul 2012
Reputation: 0
Post: #16
Where do you add the dummy files?
find quote
Post Reply