Pull request #5
+18
-18
@@ -36,30 +36,30 @@ for key, item in enumerate(data['items']):
|
|||||||
tag_notes_links[reference['uuid']] = [html.escape(item['content']['title'])]
|
tag_notes_links[reference['uuid']] = [html.escape(item['content']['title'])]
|
||||||
|
|
||||||
for key, item in enumerate(data['items']):
|
for key, item in enumerate(data['items']):
|
||||||
if item['content_type'] == 'Note':
|
if item['content_type'] == 'Note':
|
||||||
|
|
||||||
if 'title' in item['content']:
|
if 'title' in item['content']:
|
||||||
title = item['content']['title']
|
title = item['content']['title']
|
||||||
title = html.escape(title)
|
title = html.escape(title)
|
||||||
else:
|
else:
|
||||||
title = "empty title"
|
title = "empty title"
|
||||||
|
|
||||||
text = item['content']['text']
|
text = item['content']['text']
|
||||||
text = text_from_html(title, text)
|
text = text_from_html(title, text)
|
||||||
|
|
||||||
if item['uuid'] not in tag_notes_links:
|
if item['uuid'] not in tag_notes_links:
|
||||||
print(f"Whoops .... {title} had no tag ... if this is expected, then safely ignore ... Setting tag: 'Missing-Standard-Notes-Tag'.")
|
print(f"Whoops .... {title} had no tag ... if this is expected, then safely ignore ... Setting tag: 'Missing-Standard-Notes-Tag'.")
|
||||||
tag = 'Missing-Standard-Notes-Tag'
|
tag = 'Missing-Standard-Notes-Tag'
|
||||||
else:
|
else:
|
||||||
tag = '</tag><tag>'.join(tag_notes_links[item['uuid']])
|
tag = '</tag><tag>'.join(tag_notes_links[item['uuid']])
|
||||||
|
|
||||||
# remove miliseconds and timezone ... example: 2020-04-14T14:30:09.256Z => 2020-04-14T14:30:09
|
# remove miliseconds and timezone ... example: 2020-04-14T14:30:09.256Z => 2020-04-14T14:30:09
|
||||||
# we assume zulu time for all dates (UTC)
|
# we assume zulu time for all dates (UTC)
|
||||||
created_at = datetime.datetime.strptime(item['created_at'][0:19], '%Y-%m-%dT%H:%M:%S').strftime('%Y%m%dT%H%M%SZ')
|
created_at = datetime.datetime.strptime(item['created_at'][0:19], '%Y-%m-%dT%H:%M:%S').strftime('%Y%m%dT%H%M%SZ')
|
||||||
updated_at = datetime.datetime.strptime(item['updated_at'][0:19], '%Y-%m-%dT%H:%M:%S').strftime('%Y%m%dT%H%M%SZ')
|
updated_at = datetime.datetime.strptime(item['updated_at'][0:19], '%Y-%m-%dT%H:%M:%S').strftime('%Y%m%dT%H%M%SZ')
|
||||||
|
|
||||||
|
|
||||||
final_file += '''<note><title>{title}</title><content><![CDATA[<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note>{text}</en-note>]]></content><created>{created_at}</created><updated>{updated_at}</updated><tag>{tag}</tag><note-attributes><author></author><source></source><reminder-order>0</reminder-order></note-attributes></note>'''.format(title=title, text=text, tag=tag, created_at=created_at, updated_at=updated_at)
|
final_file += '''<note><title>{title}</title><content><![CDATA[<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note>{text}</en-note>]]></content><created>{created_at}</created><updated>{updated_at}</updated><tag>{tag}</tag><note-attributes><author></author><source></source><reminder-order>0</reminder-order></note-attributes></note>'''.format(title=title, text=text, tag=tag, created_at=created_at, updated_at=updated_at)
|
||||||
|
|
||||||
final_file += '''</en-export>''' # close root tag
|
final_file += '''</en-export>''' # close root tag
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user