Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Bug fixes #1  and minor changes
  • Loading branch information
aorinngoDo committed Dec 18, 2022
1 parent e6b0872 commit 943cdb2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion nicochannel_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import argparse
import xml.etree.ElementTree as ET
from xml.dom import minidom
from sanitize_filename import sanitize

ua='Mozilla/5.0'

Expand Down Expand Up @@ -100,6 +101,7 @@
filename = title + '.xml'

filename = filename.translate(str.maketrans({'\"': '”', '\'': '’', '<': '<', '>': '>', '\\': '¥', '/': '/', ':': ':', '|': '|', '?': '?', '*': '*'}))
filename = sanitize(filename)

if os.path.isfile(filename) :
print('ERROR! / File exists.')
Expand All @@ -117,7 +119,7 @@

print(oldest_time)
comments_req_data = json.loads(comments_req.text)
if len(comments_req_data) == 0 :
if len(comments_req_data) == 0 or len(comments_req_data) == 1 :
tree = minidom.parseString(ET.tostring(packet, 'utf-8'))
with open(filename,'w', encoding='utf-8') as f:
tree.writexml(f, encoding='utf-8', newl='\n', indent='')
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
requests
python-dateutil
sanitize_filename

0 comments on commit 943cdb2

Please sign in to comment.