diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-03-01 17:06:26 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-03-03 21:58:31 +0100 |
| commit | e375fdddf7cc608eefdc054d74e90bb95d573172 (patch) | |
| tree | eca3e5b384efdafa184610fae0f30f1898076f98 /scripts | |
| parent | e61267217a8ca7e65ad42bf34b6488b92eca6389 (diff) | |
Add lists of ratings.v1.8.9
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/update-ratings | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/update-ratings b/scripts/update-ratings new file mode 100755 index 00000000..5e692235 --- /dev/null +++ b/scripts/update-ratings @@ -0,0 +1,29 @@ +#!/usr/bin/python3 + +import sys +import urllib.request + +import bs4 + +# Output is +# URI (for DCP metadata) +# Name/ID of rating system +# Country[/Region] +# Country code +# Rating label + + +with urllib.request.urlopen('https://www.movielabs.com/md/ratings/v2.4.8/CMR_Ratings_v2.4.8.xml') as f, open('ratings', 'w') as g: +#with open('CMR_Ratings_v2.4.8.xml') as f, open('ratings', 'w') as g: + soup = bs4.BeautifulSoup(f.read(), 'xml') + for system in soup.find_all('mdcr:RatingSystem'): + print(system.URI.get_text(), file=g) + print(system.RatingSystemID.System.get_text(), file=g) + if system.AdoptiveRegion.SubRegion: + print(system.Region.RegionName.get_text().title() + "/" + system.AdoptiveRegion.SubRegion.get_text(), file=g) + else: + print(system.Region.RegionName.get_text().title(), file=g) + print(system.Region.country.get_text(), file=g) + for rating in system("Rating"): + print(rating.Descriptor.Label.get_text(), file=g) + |
