def onVariantPlaylist(self, playlist):
        print "Found variant playlist."
        masterPlaylist = HlsPlaylist()
        masterPlaylist.version = playlist.version

        for variant in playlist.variants:
            subOutDir = self.outDir + str(variant.bandwidth)
            print "Starting a sub hls-proxy for channel with bandwith ", variant.bandwidth, " in directory ", subOutDir
            try:
                os.mkdir(subOutDir)
            except __HOLE__:
                pass #mkdir throws if dir already exists
            subProxy = HlsProxy(self.reactor)
            subProxy.verbose = self.verbose
            subProxy.download = self.download
            subProxy.referer = self.referer
            subProxy.dump_durations = self.dump_durations
            subProxy.save_individual_playlists = self.save_individual_playlists
            subProxy.setOutDir(subOutDir)
            d = subProxy.run(variant.absoluteUrl)
            #TODO add the deffered to self.finised somehow

            masterVariant = HlsVarian()
            masterPlaylist.variants.append(masterVariant)
            masterVariant.absoluteUrl = str(variant.bandwidth) + "/stream.m3u8"
            masterVariant.programId = variant.programId
            masterVariant.bandwidth = variant.bandwidth

        self.writeFile(self.getClientPlaylist(), masterPlaylist.toStr())
dataset/ETHPy150Open Viblast/hls-proxy/hlsproxy.py/HlsProxy.onVariantPlaylist