updated History class
This commit is contained in:
parent
bafa23131a
commit
166712515d
@ -1,18 +1,36 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
class History: #Abstract class
|
class History: #Abstract class
|
||||||
def __init__(self, filename):
|
def __init__(self, filename: str):
|
||||||
self.history = list()
|
#self.history = list()
|
||||||
|
pass
|
||||||
|
|
||||||
def __size__(self):
|
def __size__(self):
|
||||||
return len(history)
|
pass
|
||||||
|
|
||||||
def parse_history(self, filename):
|
@staticmethod
|
||||||
return history
|
def parse_history(self, filename: str):
|
||||||
|
parsed_data = []
|
||||||
|
|
||||||
def is_this_type(self, filename): # bool function,
|
with open(filename, "r", encoding="utf-8") as file:
|
||||||
return false # returns false if Youtube history
|
for line in file:
|
||||||
|
line = line.strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
parsed_data.append(json.loads(line))
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
fixed_line = fix_unquoted_values(line)
|
||||||
|
parsed_data.append(json.loads(fixed_line))
|
||||||
|
|
||||||
def get_video(self, index):
|
return parsed_data
|
||||||
return history[index]
|
|
||||||
|
def is_this_type(self, filename: str): # bool function,
|
||||||
|
pass # returns false if Youtube history
|
||||||
|
|
||||||
|
def get_video(self, index: int):
|
||||||
|
pass
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return iter(history)
|
pass
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user