|
6 | 6 | # Define the RSS file and folder containing articles |
7 | 7 | docs_folder = "docs" |
8 | 8 | rss_file = os.path.join(docs_folder, "rss.xml") # Adjust path to rss.xml |
| 9 | + |
| 10 | +# Use local time instead of GMT |
| 11 | +# current_date = datetime.now().strftime("%a, %d %b %Y %H:%M:%S %z") # Local time with timezone offset |
| 12 | +# Get the current timestamp in GMT |
9 | 13 | current_date = datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S GMT") |
10 | 14 |
|
| 15 | + |
11 | 16 | def create_empty_rss_file(file_path): |
12 | 17 | """ |
13 | 18 | Create an empty RSS file with the basic structure if it doesn't exist. |
@@ -36,6 +41,7 @@ def is_file_updated(file_path, existing_pub_date): |
36 | 41 | print(f"File {file_path} has been updated (mod_time: {file_mod_time}, existing_time: {existing_time})") |
37 | 42 | return updated |
38 | 43 |
|
| 44 | + |
39 | 45 | def write_rss_feed(file_path, tree, channel): |
40 | 46 | """ |
41 | 47 | Write the updated RSS feed to the file with proper formatting using minidom. |
@@ -99,10 +105,10 @@ def write_rss_feed(file_path, tree, channel): |
99 | 105 |
|
100 | 106 | # Process each PDF file |
101 | 107 | for pdf in sorted(pdf_files): |
102 | | - relative_path = os.path.relpath(pdf, docs_folder) |
| 108 | + relative_path = os.path.relpath(pdf, start=docs_folder) # This will include docs/ and subfolders |
103 | 109 | relative_path = relative_path.replace(os.sep, "/") # Normalize to URL format |
104 | | - link = f"https://github.com/damirlj/modern_cpp_tutorials/blob/main/{relative_path}" |
105 | | - |
| 110 | + link = f"https://github.com/damirlj/modern_cpp_tutorials/blob/main/docs/{relative_path}" |
| 111 | + |
106 | 112 | # Check if the item already exists |
107 | 113 | if link in existing_items: |
108 | 114 | item = existing_items[link] |
|
0 commit comments