<commit_before>using System.IO;
using System.Collections;
using SimpleJSON;

namespace NetworkSync {
    class Playlist : SluggedItem {
        public ArrayList games = new ArrayList();
        public string parentDirectory;
        public string description;

        public Playlist(JSONNode data, string parentDir) {
            title = data["title"];
            slug = data["slug"];
            description = data["description"];
            parentDirectory = parentDir;

            WriteMetadataFile(data);

            foreach(JSONNode gameData in data["games"].AsArray) {
                games.Add(new Game(gameData, Path.Combine(parentDirectory, slug)));
            }
        }

        public ArrayList GamesToDownload() {
            GM.Instance.logger.Info("Syncing games for playlist '" + title + "'");


            ArrayList toInstall = new ArrayList();
            foreach (Game game in games) {
                System.DateTime installModified = new System.DateTime(1982, 2, 2);

                if (game.AlreadyInstalled()) {
                    installModified = System.DateTime.Parse(game.installationMetadata["last_modified"], null, System.Globalization.DateTimeStyles.RoundtripKind);
                }

                if (!game.AlreadyInstalled() || game.lastModified > installModified) {
                    GM.Instance.logger.Info("Gonna install " + game.title);
                    toInstall.Add(game);
                }
            }

            return toInstall;
        }

        public void DeleteRemovedGames() {
            SluggedItem.DeleteExtraDirectories(Path.Combine(parentDirectory, slug), games);
        }

        private void WriteMetadataFile(JSONNode data) {
            Directory.CreateDirectory(Path.Combine(parentDirectory, slug));<commit_msg>Be on guard for missing last_modified in game json.<commit_after>using System.IO;
using System.Collections;
using SimpleJSON;

namespace NetworkSync {
    class Playlist : SluggedItem {
        public ArrayList games = new ArrayList();
        public string parentDirectory;
        public string description;

        public Playlist(JSONNode data, string parentDir) {
            title = data["title"];
            slug = data["slug"];
            description = data["description"];
            parentDirectory = parentDir;

            WriteMetadataFile(data);

            foreach(JSONNode gameData in data["games"].AsArray) {
                games.Add(new Game(gameData, Path.Combine(parentDirectory, slug)));
            }
        }

        public ArrayList GamesToDownload() {
            GM.Instance.logger.Info("Syncing games for playlist '" + title + "'");


            ArrayList toInstall = new ArrayList();
            foreach (Game game in games) {
                System.DateTime installModified = new System.DateTime(1982, 2, 2);

                if (game.AlreadyInstalled() && game.installationMetadata["last_modified"] != null) {
                    installModified = System.DateTime.Parse(game.installationMetadata["last_modified"], null, System.Globalization.DateTimeStyles.RoundtripKind);
                }

                if (!game.AlreadyInstalled() || game.lastModified > installModified) {
                    GM.Instance.logger.Info("Gonna install " + game.title);
                    toInstall.Add(game);
                }
            }

            return toInstall;
        }

        public void DeleteRemovedGames() {
            SluggedItem.DeleteExtraDirectories(Path.Combine(parentDirectory, slug), games);
        }

        private void WriteMetadataFile(JSONNode data) {
            Directory.CreateDirectory(Path.Combine(parentDirectory, slug));
{'fraction_non_alphanumeric': 0.09679173463839043, 'fraction_numerical': 0.0032626427406199023, 'mean_word_length': 2.152527849185947, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '665306', 'n_tokens_mistral': 917, 'n_tokens_neox': 854, 'n_words': 199}