Skip to content

Commit 14c5334

Browse files
committed
In the "Stories" module, I have made the following changes:
In the root class, I greatly improved the definition of the story links dictionary. This now contains the keys "Website", "Wattpad", and "Spirit Fanfics". The class defines the story's website links, and the story IDs, links, and custom links on Wattpad and Spirit Fanfics. Now the "Website" dictionary is written to its new JSON file of the same name. The same goes for the "Spirit Fanfics" links dictionary and its new JSON file. In the root class, I have made the following changes: I created the new root method "Define_Story_Websites_Dictionary". To define the dictionaries of story websites, with their link templates and additional links. It also creates the "Story websites" dictionary, writing on the JSON file of the same name. And I also created the "Define_Story_Websites" method. To define the story website dictionary inside each story dictionary. In its "Create_New_Story" sub-class, I added more requests for information about the story. For example, ask the user if the story has a parent story, if so, ask for the title of the parent story. The sub-class also asks if the user posted the story on the story "Wattpad" and "Spirit Fanfics" story websites. If so, the sub-class asks for the IDs of the story on both websites and in all supported languages. Thus creating the story website dictionaries. I also moved the story dictionary key definition code to the new "Define_Story_Dictionary" method, to make it more organized.
1 parent 2a88c4f commit 14c5334

File tree

6 files changed

+492
-59
lines changed

6 files changed

+492
-59
lines changed

Module Files/Food_Time/Times.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"Will be hungry": 3
1111
},
1212
"Ate": {
13-
"Object": "2024-04-29 19:48:03-03:00",
13+
"Object": "2024-04-30 23:59:42-03:00",
1414
"Time": 0,
15-
"Time text": "19:48",
15+
"Time text": "23:59",
1616
"Unit": {
1717
"en": "hours",
1818
"pt": "horas"
@@ -23,9 +23,9 @@
2323
}
2424
},
2525
"Can drink water": {
26-
"Object": "2024-04-29 20:28:03-03:00",
26+
"Object": "2024-05-01 00:39:42-03:00",
2727
"Time": 40,
28-
"Time text": "20:28",
28+
"Time text": "00:39",
2929
"Unit": {
3030
"en": "minutes",
3131
"pt": "minutos"
@@ -36,9 +36,9 @@
3636
}
3737
},
3838
"Will be hungry": {
39-
"Object": "2024-04-29 22:48:03-03:00",
39+
"Object": "2024-05-01 02:59:42-03:00",
4040
"Time": 3,
41-
"Time text": "22:48",
41+
"Time text": "02:59",
4242
"Unit": {
4343
"en": "hours",
4444
"pt": "horas"

Module Files/Stories/Texts.json

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
"en": "websites update",
3636
"pt": "atualização de sites"
3737
},
38-
"wattpad_chapter_posting": {
39-
"en": "Wattpad chapter posting",
40-
"pt": "postagem do capítulo no Wattpad"
38+
"story_website_chapter_posting": {
39+
"en": "story website chapter posting on the story websites",
40+
"pt": "postagem do capítulo nos sites de história"
4141
},
4242
"social_network_posting": {
4343
"en": "Social Network posting",
@@ -199,10 +199,6 @@
199199
"en": "Translate",
200200
"pt": "Traduzir"
201201
},
202-
"obsidian_link": {
203-
"en": "Obsidian link",
204-
"pt": "Link do Obsidian"
205-
},
206202
"press_enter_to_start_counting_{}_time": {
207203
"en": "Press Enter to start counting {} time",
208204
"pt": "Pressione Enter para começar a contar o tempo de {}"
@@ -386,5 +382,21 @@
386382
"select_an_additional_author": {
387383
"en": "Select an additional author",
388384
"pt": "Selecione um autor adicional"
385+
},
386+
"does_the_story_has_a_parent_story": {
387+
"en": "Does the story has a parent story",
388+
"pt": "A história tem uma história parental"
389+
},
390+
"type_the_title_of_the_parent_story": {
391+
"en": "Type the title of the parenet story",
392+
"pt": "Digite o título da história parental"
393+
},
394+
"did_you_posted_the_story_on_the_story_website": {
395+
"en": "Did you posted the story on the story website",
396+
"pt": "Você postou a história no site de história"
397+
},
398+
"id_of_the_story_in": {
399+
"en": "ID of the story in",
400+
"pt": "ID da história em"
389401
}
390402
}

Modules/Stories/Create_New_Story/__init__.py

Lines changed: 135 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ def __init__(self):
1616
# Type the information about the story
1717
self.Type_Story_Information()
1818

19+
# Define the "Story" dictionary
20+
self.Define_Story_Dictionary()
21+
1922
# Create the folders of the story
2023
self.Create_Story_Folders()
2124

@@ -47,6 +50,8 @@ def Type_Story_Information(self):
4750
print()
4851
print(self.separators["5"])
4952

53+
# ---------- #
54+
5055
# Ask for the titles of the story
5156
for language in self.languages["small"]:
5257
# Get the translated language
@@ -215,42 +220,152 @@ def Type_Story_Information(self):
215220

216221
# ---------- #
217222

223+
# Ask if the story has a parent story
224+
question = self.language_texts["does_the_story_has_a_parent_story"]
225+
226+
if self.switches["testing"] == False:
227+
parent_story = self.Input.Yes_Or_No(question)
228+
229+
else:
230+
parent_story = True
231+
232+
# If the story has a parent story
233+
if parent_story == True:
234+
# Ask for the title of the parent story
235+
type_text = self.language_texts["type_the_title_of_the_parent_story"]
236+
237+
if self.switches["testing"] == False:
238+
title = self.Input.Type(type_text, accept_enter = False, next_line = True)
239+
240+
else:
241+
title = "Parent Story Title"
242+
243+
# Create the "Parent story" dictionary
244+
story["Information"]["Parent story"] = {
245+
"Title": title
246+
}
247+
248+
# ---------- #
249+
250+
# Define the "Links" dictionary
251+
story["Information"]["Links"] = {
252+
"Website": {}
253+
}
254+
255+
# ---------- #
256+
257+
# "Wattpad" and "Spirit Fanfics" dictionaries
258+
259+
# Iterate through the dictionary of story websites
260+
for key, story_website in self.stories["Story websites"]["Dictionary"].items():
261+
# Ask if the user posted the story on the story website
262+
question = self.language_texts["did_you_posted_the_story_on_the_story_website"] + ' "' + key + '"'
263+
264+
if self.switches["testing"] == False:
265+
posted_story = self.Input.Yes_Or_No(question)
266+
267+
else:
268+
posted_story = True
269+
270+
# If the user posted the story
271+
if posted_story == True:
272+
# Define the "Story websites" dictionary for the story
273+
self.Define_Story_Websites(story)
274+
275+
# ---------- #
276+
277+
# Define the "story" variable in the class so it is available to the "Define_Story_Dictionary" method
278+
self.story = story
279+
280+
def Define_Story_Dictionary(self):
218281
# Define the "Readers" dictionary
219-
story["Information"]["Readers"] = {
282+
self.story["Information"]["Readers"] = {
220283
"Number": 0,
221284
"List": []
222285
}
223286

287+
# ---------- #
288+
224289
# Define the story "Pack" dictionary
225-
story["Information"]["Pack"] = deepcopy(self.stories["Story pack"])
290+
self.story["Information"]["Pack"] = deepcopy(self.stories["Story pack"])
291+
292+
# ---------- #
226293

227294
# Define the "Writing" dictionary
228-
story["Information"]["Writing"] = {}
295+
self.story["Information"]["Writing"] = {}
229296

230297
for writing_mode in self.texts["writing_modes, type: list"]["en"]:
231-
story["Information"]["Writing"][writing_mode] = {
298+
self.story["Information"]["Writing"][writing_mode] = {
232299
"Chapter": 0,
233300
"Times": {
234301
"First": "",
235302
"Last": ""
236303
}
237304
}
238305

239-
# Define the "Website" dictionary
240-
story["Information"]["Website"] = {
241-
"Link": self.links["Stake2 Website"] + story["Title"] + "/"
306+
# ---------- #
307+
308+
# "Website" dictionary
309+
310+
# Create the empty "Website" dictionary with the "Link" and "Links" keys
311+
self.story["Information"]["Website"] = {
312+
"Link": "",
313+
"Links": {}
242314
}
243315

244-
# Define the "Wattpad" dictionary
245-
story["Information"]["Wattpad"] = {}
316+
# Define the story website folder as the story title
317+
website_folder = self.story["Title"]
318+
319+
# If the story has a parent story
320+
if "Parent story" in self.story["Information"]:
321+
# Get the parent story dictionary
322+
parent_story = self.story["Information"]["Parent story"]
323+
324+
# Define the website folder
325+
website_folder = parent_story["Title"]
326+
327+
# If the parent story has a custom folder, use it
328+
if "Folder" in parent_story:
329+
website_folder = parent_story["Folder"]
330+
331+
# Add the story title to the website folder
332+
website_folder += "/" + self.story["Title"]
333+
334+
# Define the website folder
335+
self.story["Information"]["Website"]["Website folder"] = "/" + website_folder + "/"
336+
337+
# Update the website "Link" key with the website folder
338+
self.story["Information"]["Website"]["Link"] = self.links["Stake2 Website"] + website_folder + "/"
339+
340+
# Iterate through the list of small languages
341+
for language in self.languages["small"]:
342+
# Define the language link with the language folder
343+
self.story["Information"]["Website"]["Links"][language] = self.story["Information"]["Website"]["Link"] + language + "/"
344+
345+
# Update the "Website" dictionary inside the "Links" dictionary with the dictionary above
346+
self.story["Information"]["Links"]["Website"] = self.story["Information"]["Website"]
246347

247348
# ---------- #
248349

249-
# Define the root "Story" dictionary as the local dictionary
250-
self.dictionary["Story"] = story
350+
# "Wattpad" and "Spirit Fanfics" dictionaries
251351

252-
# Add the story to the object of this class for easier typing
253-
self.story = story
352+
# Iterate through the dictionary of story websites
353+
for key, story_website in self.stories["Story websites"]["Dictionary"].items():
354+
# Define the story website dictionary if it is not already present
355+
if key not in self.story["Information"]:
356+
# Define it as the story website root link template
357+
self.story["Information"][key] = story_website["Templates"]["Root"]
358+
359+
# Update the story website dictionary inside the "Links" dictionary with the dictionary above
360+
self.story["Information"]["Links"][key] = self.story["Information"][key]
361+
362+
# Define the "Story websites" dictionary for the story to update the JSON files for the story websites
363+
self.Define_Story_Websites(self.story)
364+
365+
# ---------- #
366+
367+
# Define the root "Story" dictionary as the local dictionary
368+
self.dictionary["Story"] = self.story
254369

255370
def Create_Story_Folders(self):
256371
# Define and create the story folder
@@ -332,6 +447,13 @@ def Update_Files(self):
332447

333448
# ---------- #
334449

450+
# Remove the keys inside the "Links" dictionary if they exist outside of it
451+
for key in self.story["Information"]["Links"]:
452+
if key in self.story["Information"]:
453+
self.story["Information"].pop(key)
454+
455+
# ---------- #
456+
335457
# Update the "Story.json" file with the new story "Information" dictionary
336458
self.JSON.Edit(self.story["Folders"]["Story"], self.story["Information"])
337459

Modules/Stories/Post/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def __init__(self, run_as_module = False):
1717
"Update websites": {
1818
"Text key": "websites_update"
1919
},
20-
"Post on Wattpad": {
21-
"Text key": "wattpad_chapter_posting"
20+
"Post on story websites": {
21+
"Text key": "story_website_chapter_posting"
2222
},
2323
"Post on Social Networks": {
2424
"Text key": "social_network_posting"
@@ -499,7 +499,7 @@ def Copy_Chapter_Text(self, language, full_language):
499499
# Copy the chapter text
500500
self.Text.Copy(chapter_text, verbose = False)
501501

502-
def Post_On_Wattpad(self):
502+
def Post_On_Story_Websites(self):
503503
# Show a five dash separator
504504
print()
505505
print(self.separators["5"])
@@ -513,7 +513,7 @@ def Post_On_Wattpad(self):
513513

514514
# Define the Wattpad link variable for easier typing
515515
# With the Wattpad link of the story in the current language
516-
wattpad_link = self.story["Information"]["Wattpad"][language]["Link"]
516+
wattpad_link = self.story["Information"]["Links"]["Wattpad"]["Links"][language]
517517

518518
# Define the "Social Networks" dictionary to use in the "Open_Social_Network" sub-class
519519
# With the list of social networks to open, and their custom links

0 commit comments

Comments
 (0)