1
0
Fork 0
mirror of synced 2024-06-03 10:54:38 +12:00
bulk-downloader-for-reddit/src/store.py
Ali Parlakçı af1f9fd365
v1.9.0 (#114)
* IMGUR API is no longer used

* --skip now accepts file types instead of domain

* --skip-domain added

* --no-download added

* --no-dupe now supports YouTube

* Duplicates of older posts will not be dowloaded if --no-dupe and --downloaded-posts options are given together

* Invalid characters in MacOS and Linux platforms are removed from filenames

* Bug fixes
2020-06-03 18:10:25 +03:00

25 lines
675 B
Python

from os import path
class Store:
def __init__(self,directory=None):
self.directory = directory
if self.directory:
if path.exists(directory):
with open(directory, 'r') as f:
self.list = f.read().split("\n")
else:
with open(self.directory, 'a'):
pass
self.list = []
else:
self.list = []
def __call__(self):
return self.list
def add(self, data):
self.list.append(data)
if self.directory:
with open(self.directory, 'a') as f:
f.write("{data}\n".format(data=data))