Exemplo n.º 1
0
        public static MultiSourceHLSDownloadInfo?LoadMultiSourceHLSDownloadInfo(string id)
        {
            try
            {
                using var s = new FileStream(Path.Combine(Config.DataDir, id + ".info"), FileMode.Open);
                using var r = new BinaryReader(s);

                var info = new MultiSourceHLSDownloadInfo
                {
                    VideoUri = StreamHelper.ReadString(r),
                    AudioUri = StreamHelper.ReadString(r),
                    File     = StreamHelper.ReadString(r)
                };
                StreamHelper.ReadStateHeaders(r, out Dictionary <string, List <string> > headers);
                info.Headers = headers;
                StreamHelper.ReadStateCookies(r, out Dictionary <string, string> cookies);
                info.Cookies = cookies;
                return(info);
            }
            catch (Exception ex)
            {
                Log.Debug(ex, ex.Message);
            }
            return(null);
        }
Exemplo n.º 2
0
 public static void SaveDownloadInfo(string id, MultiSourceHLSDownloadInfo info)
 {
     using var s = new FileStream(Path.Combine(Config.DataDir, id + ".info"), FileMode.Create);
     using var w = new BinaryWriter(s);
     WriteStringSafe(info.VideoUri, w);
     WriteStringSafe(info.AudioUri, w);
     WriteStringSafe(info.File, w);
     StreamHelper.WriteStateHeaders(info.Headers, w);
     StreamHelper.WriteStateCookies(info.Cookies, w);
     //File.WriteAllText(Path.Combine(Config.DataDir, id + ".info"), JsonConvert.SerializeObject(downloadInfo));
 }