Skip to content

Commit

Permalink
use xbmcvfs to read description files
Browse files Browse the repository at this point in the history
  • Loading branch information
maloep committed Jan 6, 2018
1 parent 7252beb commit 610d69e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions resources/lib/pyscraper/descriptionparser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

import xbmcvfs
import time
import urllib2
from util import Logutil as log
Expand All @@ -18,8 +19,8 @@ def downloadDescription(self, descriptionUrl):

def openFile(self, descriptionFilepath):
try:
with open(str(descriptionFilepath), 'r') as fh:
return fh.read()
fh = xbmcvfs.File(str(descriptionFilepath))
return fh.read()
except Exception as e:
log.error("Unable to open metadata from {0}: {1}".format(descriptionFilepath, e))

Expand Down
4 changes: 2 additions & 2 deletions resources/lib/pyscraper/pyscraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ def prepareScraperSource(self, scraper, scraperSourceOrig, romFilename):
for i in range(0, len(replaceTokens)):
scraperSource = scraperSource.replace(replaceTokens[i], replaceValues[i])

if not scraperSource.startswith('http') and not os.path.exists(scraperSource):
if not scraperSource.startswith('http') and not xbmcvfs.exists(scraperSource):
# try again with original rom filename
scraperSource = scraperSourceOrig.replace("%GAME%", romFilename)
if not os.path.exists(scraperSource):
if not xbmcvfs.exists(scraperSource):
log.warn("description file for game {0} could not be found. Check if this path exists: {1}".format(gamenameFromFile, scraperSource))
return ""

Expand Down

0 comments on commit 610d69e

Please sign in to comment.