Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from urllib2 import quote, unquote
import sqlite3
def fix_the_things(name):
name = name[6:]
name = quote(unquote(name), '-_.!()')
name = name.replace('.rar%2F', '.rar/')
bits = name.split('%')
res = [bits[0]]
for item in bits[1:]:
res.append('%')
res.append(item[:2].lower())
res.append(item[2:])
return 'rar://%s' % ''.join(res)
def main():
conn = sqlite3.connect('MyVideos75.db')
cursor = conn.cursor()
cursor.execute(
'select idFile, strFileName from files where strFilename like "rar://%"'
)
results = [
[
r[0],
fix_the_things(r[1]),
]
for r in cursor.fetchall()
]
for r in results:
cursor.execute(
'update files set strFilename = ? where idFile = ?',
(r[1], r[0])
)
conn.commit()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment