Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- import shutil
- from xml.etree import ElementTree as et
- import fileinput
- CLONE_NAME = 'YOUR_NAME_HERE'
- ADDON_PATH = '/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/'
- SAN_NAME = 'script.lazytv.' + CLONE_NAME
- SCRIPT_PATH = os.path.join(ADDON_PATH, 'script.lazytv')
- NEW_PATH = os.path.join(ADDON_PATH, SAN_NAME)
- # copy current addon to new location
- IGNORE_PATTERNS = ('.pyc','CVS','.git','tmp','.svn')
- shutil.copytree(SCRIPT_PATH,NEW_PATH, ignore=shutil.ignore_patterns(*IGNORE_PATTERNS))
- # remove the unneeded files
- ADDON_FILE = os.path.join(NEW_PATH,'addon.xml')
- os.remove(os.path.join(NEW_PATH,'service.py'))
- os.remove(ADDON_FILE)
- os.remove(os.path.join(NEW_PATH,'resources','settings.xml'))
- os.remove(os.path.join(NEW_PATH,'resources','clone.py'))
- # replace the settings file and addon file with the truncated one
- shutil.move( os.path.join(NEW_PATH,'resources','addon_clone.xml') , ADDON_FILE )
- shutil.move( os.path.join(NEW_PATH,'resources','settings_clone.xml') , os.path.join(NEW_PATH,'resources','settings.xml') )
- # edit the addon.xml to point to the right folder
- tree = et.parse(ADDON_FILE)
- root = tree.getroot()
- root.set('id', SAN_NAME)
- root.set('name', CLONE_NAME)
- tree.find('.//summary').text = CLONE_NAME
- tree.write(ADDON_FILE)
- # replace the id on these files, avoids Access Violation
- py_files = [os.path.join(NEW_PATH,'resources','selector.py') , os.path.join(NEW_PATH,'resources','playlists.py'),os.path.join(NEW_PATH,'resources','update_clone.py'),os.path.join(NEW_PATH,'resources','episode_exporter.py')]
- for py in py_files:
- for line in fileinput.input(py, inplace = 1): # Does a list of files, and writes redirects STDOUT to the file in question
- print line.replace('script.lazytv',SAN_NAME),
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement