Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time, json
- from urllib.parse import urlparse, urlunparse
- class tab:
- def __init__(self, url, title):
- self.url = url; self.title = title
- self.favIconUrl = urlunparse(urlparse(url)._replace(path='favicon.ico',params='',query='',fragment=''))
- self.pinned = False; self.muted = False
- _id, res, tabs, urls = int(time.time() * 1000), [], [], []
- lines = open('onetab.txt').readlines()
- for ln in lines:
- if ln is '\n':
- _id = _id - 60000
- res.append({
- "_id": _id, "time": _id,
- "title": "", "tags": [],
- "tabs": tabs, "urls": urls,
- "lock": False, "star": False
- })
- tabs, urls = [], []
- continue
- token = ln.strip().split('|', 2)
- url, title = token[0].strip(), '|'.join(token[1:])
- t = tab(url, title)
- tabs.append(t.__dict__)
- urls.append(url)
- _id = _id - 60000
- res.append({
- "_id": _id, "time": _id,
- "title": "", "tags": [],
- "tabs": tabs, "urls": urls,
- "lock": False, "star": False
- })
- with open('onetab.json', 'w') as f:
- json.dump(res, f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement