summaryrefslogtreecommitdiff
path: root/src/tirante/chapter_images_manager.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/tirante/chapter_images_manager.py')
-rw-r--r--src/tirante/chapter_images_manager.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/tirante/chapter_images_manager.py b/src/tirante/chapter_images_manager.py
new file mode 100644
index 0000000..1b8afbc
--- /dev/null
+++ b/src/tirante/chapter_images_manager.py
@@ -0,0 +1,33 @@
+from tirante.get_chapter_image_list import get_chapter_image_list
+
+
+def chapter_images_list_to_csv(chapter_data):
+ """
+ Creates csv file for a chapter, given the list.
+ chapter_data: A list containing a url and a title.
+ """
+
+ ch_name = ''.join([chapter_data[1], '.csv'])
+
+ chapter_image_list = get_chapter_image_list(chapter_data)
+
+ with open(ch_name, 'w') as outcsv:
+ for image in chapter_image_list:
+ outcsv.write(''.join([image[0], ',', image[1], '\n']))
+
+
+def chapter_images_csv_to_list(chapter_image_csv):
+ """
+ Returns a list given the csv file.
+ chapter_image_csv: csv containing data for the chapter.
+ """
+
+ out_chapter_image_list = []
+
+ with open(chapter_image_csv, 'r') as incsv:
+ lines = incsv.readlines()
+ for line in lines:
+ # print(line.strip().split(','))
+ out_chapter_image_list.append(line.strip().split(','))
+
+ return out_chapter_image_list