summaryrefslogtreecommitdiff
path: root/src/tirante/chapters_manager.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/tirante/chapters_manager.py')
-rw-r--r--src/tirante/chapters_manager.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/tirante/chapters_manager.py b/src/tirante/chapters_manager.py
new file mode 100644
index 0000000..3d99c3f
--- /dev/null
+++ b/src/tirante/chapters_manager.py
@@ -0,0 +1,31 @@
+def chapters_list_to_csv(chapters_list,
+ manga_name):
+ """
+ Creates a csv file from the input chapter_list.
+ chapters_list: List of data of the chapters.
+ manga_name: Name of the manga, folder naming friendly.
+ """
+
+ # Adding '.csv' for csv creation.
+ m_name_ext = ''.join([manga_name, '.csv'])
+ # print(m_name)
+
+ with open(m_name_ext, 'w') as outcsv:
+ for chapter in chapters_list:
+ outcsv.write(''.join([chapter[0], ',', chapter[1], '\n']))
+
+
+def chapters_csv_to_list(chapter_csv):
+ """
+ Gives a list of chaptesrs from a csv file.
+ chapters_list: List of data of the chapters.
+ """
+
+ out_chapters_list = []
+
+ with open(chapter_csv, 'r') as incsv:
+ lines = incsv.readlines()
+ for line in lines:
+ out_chapters_list.append(line.strip().split(','))
+
+ return out_chapters_list