<commit_before>import xml.etree.ElementTree as ET
import json
import re
from svtplay_dl.log import log
from svtplay_dl.utils import is_py2, is_py3, decode_html_entities
from svtplay_dl.utils.io import StringIO
from svtplay_dl.output import output
from requests import Session
from requests import __build__ as requests_version
import platform


class subtitle(object):
    def __init__(self, options, subtype, url, subfix = None):
        self.url = url
        self.subtitle = None
        self.options = options
        self.subtype = subtype
        self.http = Session()
        self.subfix = subfix

    def download(self):
        subdata = self.http.request("get", self.url, cookies=self.options.cookies)
        
        data = None
       
        if self.subtype == "tt":
            data = self.tt(subdata)
        if self.subtype == "json":
            data = self.json(subdata)
        if self.subtype == "sami":
            data = self.sami(subdata)
        if self.subtype == "smi":
            data = self.smi(subdata)
        if self.subtype == "wrst":
            data = self.wrst(subdata)
        if self.subtype == "raw":
            data = self.raw(subdata)
        
        if self.subfix:
            self.options.output = self.options.output + self.subfix
            
        if(self.options.get_raw_subtitles):
            subdata = self.raw(subdata)
            self.save_file(subdata, self.subtype)
        
        self.save_file(data, "srt")


        
    def save_file(self, data, subtype):
        
        if platform.system() == "Windows" and is_py3:
            file_d = output(self.options, subtype, mode="wt", encoding="utf-8")
        else:<commit_msg>subtitle: removed parentesis in if check<commit_after>import xml.etree.ElementTree as ET
import json
import re
from svtplay_dl.log import log
from svtplay_dl.utils import is_py2, is_py3, decode_html_entities
from svtplay_dl.utils.io import StringIO
from svtplay_dl.output import output
from requests import Session
from requests import __build__ as requests_version
import platform


class subtitle(object):
    def __init__(self, options, subtype, url, subfix = None):
        self.url = url
        self.subtitle = None
        self.options = options
        self.subtype = subtype
        self.http = Session()
        self.subfix = subfix

    def download(self):
        subdata = self.http.request("get", self.url, cookies=self.options.cookies)
        
        data = None
       
        if self.subtype == "tt":
            data = self.tt(subdata)
        if self.subtype == "json":
            data = self.json(subdata)
        if self.subtype == "sami":
            data = self.sami(subdata)
        if self.subtype == "smi":
            data = self.smi(subdata)
        if self.subtype == "wrst":
            data = self.wrst(subdata)
        if self.subtype == "raw":
            data = self.raw(subdata)
        
        if self.subfix:
            self.options.output = self.options.output + self.subfix
            
        if self.options.get_raw_subtitles:
            subdata = self.raw(subdata)
            self.save_file(subdata, self.subtype)
        
        self.save_file(data, "srt")


        
    def save_file(self, data, subtype):
        
        if platform.system() == "Windows" and is_py3:
            file_d = output(self.options, subtype, mode="wt", encoding="utf-8")
        else:
{'fraction_non_alphanumeric': 0.10005868544600939, 'fraction_numerical': 0.002347417840375587, 'mean_word_length': 2.0850678733031676, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '6020351', 'n_tokens_mistral': 1044, 'n_tokens_neox': 1029, 'n_words': 253}