This commit is contained in:
olari
2019-04-13 22:28:43 +03:00
commit cbf6cd3f07
19 changed files with 1066 additions and 0 deletions

45
python/text/mal_list_render.py Executable file
View File

@@ -0,0 +1,45 @@
#!/usr/bin/env python3
import bs4
import sys
import os
import glob
# converts MyAnimeList's XML exports to readable (but less informative) text files.
animelists = glob.glob('animelist*.xml')
for animelist in animelists:
with open(animelist, 'r') as xml, open(animelist + '.txt', 'w') as file:
soup = bs4.BeautifulSoup(xml.read(), 'html.parser')
completed = []
ptw = []
movies = []
for anime in soup.select('anime'):
line = anime.select('series_title')[0].text + ' ' + anime.select('my_watched_episodes')[0].text + '/' + anime.select('series_episodes')[0].text + '\n'
series_type = anime.select('series_type')[0].text
status = anime.select('my_status')[0].text
if series_type == 'Movie':
movies.append(line)
continue
if status == 'Completed':
completed.append(line)
elif status == 'Plan to Watch':
ptw.append(line)
for title in completed:
file.write(title)
file.write('\n')
for title in ptw:
file.write(title)
file.write('\n')
for title in movies:
file.write(title)