46 lines
1.1 KiB
Python
Executable File
46 lines
1.1 KiB
Python
Executable File
#!/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)
|