public void ImportPlaylist() { ILogger logger = ServiceRegistration.Get <ILogger>(); SaveSettings(); string importFile = ImportFile; if (!File.Exists(importFile)) { logger.Warn("PlaylistImportModel: Cannot import playlist, playlist file '{0}' does not exist", importFile); return; } logger.Info("PlaylistImportModel: Importing playlist '{0}'", importFile); IServerConnectionManager scm = ServiceRegistration.Get <IServerConnectionManager>(); IContentDirectory cd = scm.ContentDirectory; if (cd == null) { logger.Warn("PlaylistImportModel: Cannot import playlist, the server is not connected"); return; } IList <string> mediaFiles = M3U.ExtractFileNamesFromPlaylist(importFile); IThreadPool threadPool = ServiceRegistration.Get <IThreadPool>(); threadPool.Add(() => RunImportOperationAsync(cd, mediaFiles)); }
public void AllTests() { var simple_vod = M3U.Parse(Sample.simple_vod); Assert.AreEqual(simple_vod.PlayListType, "VOD"); Assert.AreEqual(simple_vod.Medias.Last().Duration, 9); var format_specs = M3U.Parse(Sample.format_specs); Assert.AreEqual(format_specs.Medias.Last().MediaFile, "udp://225.55.55.4:1234"); Assert.AreEqual(format_specs.Medias.Last().Title.RawTitle, "MTV"); var sample_paste_bin = M3U.Parse(Sample.sample_paste_bin); Assert.AreEqual(sample_paste_bin.Medias.ElementAt(10).Attributes.TvgLogo, "http://greektv.pbworks.com/f/ANT1.png"); var header_with_parameters = M3U.Parse(Sample.header_with_parameters); Assert.AreEqual(header_with_parameters.Attributes.Cache, 500); var iptv_sample = M3U.Parse(Sample.iptv_sample); Assert.AreEqual(iptv_sample.Medias.ElementAt(2).Attributes.TvgShift, "+1"); var big_list = M3U.Parse(Sample.big_list); Assert.AreEqual(big_list.Medias.Count(), 902); }
private async void ImportPlaylists() { var picker = new FileOpenPicker(); FileOpenPicker openPicker = new FileOpenPicker(); openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.MusicLibrary; openPicker.FileTypeFilter.Add(".m3u"); openPicker.FileTypeFilter.Add(".pls"); StorageFile file = await openPicker.PickSingleFileAsync(); if (file != null) { IPlaylist playlist = null; if (Path.GetExtension(file.Path) == ".m3u") { playlist = new M3U(); } else { playlist = new PLS(); } var plist = new Playlist() { Name = file.DisplayName }; Messenger.Instance.NotifyColleagues(MessageTypes.MSG_ADD_PLAYLIST, plist); await playlist.LoadPlaylist(file).ConfigureAwait(false); } }
public override void GenerateHeaders() { whc = new WebHeaderCollection(); whc.Add("DNT", "1"); whc.Add("Sec-Fetch-Dest", "document"); whc.Add("Sec-Fetch-Site", "none"); whc.Add("Accept", "video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5"); //Get anime slug to use for api ADLUpdates.CallLogUpdate("Getting anime title and episode list from api.twist.moe"); string k = ao.term.TrimToSlash(keepSlash: false).SkipCharSequence("https://twist.moe/a/".ToCharArray()); string uri = $"https://api.twist.moe/api/anime/{k}"; wRequest = (HttpWebRequest)WebRequest.Create(uri); wRequestSet(); WebResponse wb = wRequest.GetResponse(); string decodedContent = M3U.DecryptBrotliStream(wb.GetResponseStream()); info = JsonSerializer.Deserialize <TwistMoeAnimeInfo>(decodedContent); wRequest = (HttpWebRequest)WebRequest.Create($"https://api.twist.moe/api/anime/{k}/sources"); wRequestSet(); wb = wRequest.GetResponse(); decodedContent = M3U.DecryptBrotliStream(wb.GetResponseStream()); info.episodes = JsonSerializer.Deserialize <List <Episode> >(decodedContent); }
async void ImportPlaylists() { var picker = new FileOpenPicker(); FileOpenPicker openPicker = new FileOpenPicker(); openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.MusicLibrary; openPicker.FileTypeFilter.Add(".m3u"); openPicker.FileTypeFilter.Add(".pls"); StorageFile file = await openPicker.PickSingleFileAsync(); IPlaylist playlist = null; if (Path.GetExtension(file.Path) == ".m3u") { playlist = new M3U(); } else { playlist = new PLS(); } var dict = await playlist.LoadPlaylist(file); LibVM.AddPlaylist(dict, file.DisplayName, ""); }
private bool DownloadVidstream(HentaiVideo video) { if (ao.stream) { startStreamServer(); } WebClient webC = new WebClient(); webC.Headers = headersCollection; if (video.slug.IsMp4() == true) { updateStatus(taskIndex, $"Downloading MP4 {video.slug}"); webC.DownloadProgressChanged += WebC_DownloadProgressChanged; webC.DownloadFile(video.slug, $"{downloadTo}\\{video.name}.mp4"); updateStatus(taskIndex, $"Finished Downloading: {video.slug}, [##########] 100%"); return(true); } else { M3U m3 = new M3U(webC.DownloadString(video.slug), headersCollection, video.slug.TrimToSlash()); int l = m3.Size; double prg = (double)m3.location / (double)l; Byte[] b; while ((b = m3.getNext()) != null) { if (ao.stream) { publishToStream(b); } updateStatus(taskIndex, $"{video.name} {Strings.calculateProgress('#', m3.location, l)}"); mergeToMain($"{downloadTo}\\{video.name}.mp4", b); } } return(true); }
static void Main(string[] args) { //var customFile = Path.Combine(@"C:\Data\Desktop", "test.m3u"); //var customM3u = M3U.ParseFromFile(customFile); var simpleVodM3u = M3U.Parse(simpleVod); var headerParameterM3u = M3U.Parse(headerParameter); }
private void downloadVideo(string url, int number) { number++; string parsedTitle = info.title.RemoveSpecialCharacters(); if (ao.l) { downloadTo = ao.export; } else if (ao.android) { downloadTo = Path.Combine(ao.export, "Anime", parsedTitle); } else { downloadTo = Path.Combine(ao.export, parsedTitle); } M3U m3 = new M3U(url, whc, null, true, new M3UMP4_SETTINGS() { Host = "cdn.twist.moe", Referer = $"https://twist.moe/", Headers = whc }); Byte[] b; FileStream fs = null; if (ao.stream || ao.streamOnly) { startStreamServer(); } while ((b = m3.getNextStreamBytes()) != null) //TODO: Rewrite download continuation code. { if (ao.streamOnly) { videoStream.addNewBytes(b); } else { if (ao.stream) { videoStream.addNewBytes(b); } // Init if (fs == null) { Directory.CreateDirectory(downloadTo); fs = new FileStream($"{downloadTo}{Path.DirectorySeparatorChar}{parsedTitle}_{number}.mp4", FileMode.OpenOrCreate); } fs.Write(b); } } }
// Load List 2 public void LoadM3u(string[] FilePaths) { if (Path.GetExtension(FilePaths[0]).ToLower() != ".m3u") { return; } string[] L = M3U.Load(FilePaths[0]); AddNewFiles(L); }
public void hidePathTest() { M3U backend = new M3U(); // List as argument List <string> resultList = backend.HidePath(paths); // String as argument //string resultStr = backend.HidePath(path); //Console.WriteLine(resultList[resultList.Count - 1]); foreach (string i in resultList) { Console.WriteLine(i); } }
public static List <Source> Deserialize(String playlistText) { var m3uPLaylist = M3U.Parse(playlistText); var result = new List <Source>(m3uPLaylist.Medias.Count()); foreach (var media in m3uPLaylist.Medias) { result.Add(new Source { Title = media.Title.InnerTitle, Url = media.MediaFile, }); } return(result); }
private void GenerateTwistCache(bool exportToDisk = false) { string data = string.Empty; wRequest = (HttpWebRequest)WebRequest.Create("https://api.twist.moe/api/anime"); wRequestSet(); WebResponse wb = wRequest.GetResponse(); string decodedContent = M3U.DecryptBrotliStream(wb.GetResponseStream()); if (exportToDisk) { Byte[] bytes = Encoding.UTF8.GetBytes(decodedContent); using (FileStream fs = new FileStream($"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}twistIndex.json", FileMode.Create)) fs.Write(bytes, 0, bytes.Length); } LoadTwistCache(decodedContent); }
// Save list as .m3u public void SaveList() { SaveFileDialog FileDialog = new SaveFileDialog(); FileDialog.Filter = "M3U files(*.m3u)|*.m3u"; FileDialog.Title = "Save files list"; if (FileDialog.ShowDialog() == true) { FileInfo SF = new FileInfo(FileDialog.FileName); ArrayList A = new ArrayList(); foreach (var st in collection) { FileInfo F = new FileInfo(st.FilePath); A.Add(F.FullName); } M3U.Save(FileDialog.FileName, (string[])A.ToArray(typeof(string))); MessageBox.Show("List saved successfully."); } }
async void ImportPlaylists() { var picker = new FileOpenPicker(); FileOpenPicker openPicker = new FileOpenPicker(); openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.MusicLibrary; openPicker.FileTypeFilter.Add(".m3u"); openPicker.FileTypeFilter.Add(".pls"); StorageFile file = await openPicker.PickSingleFileAsync(); if(file != null) { var plist = new Playlist() { Name = file.DisplayName }; LibVM.AddPlaylist(plist); LibVM.Database.playlists.Insert(plist); IPlaylist playlist = null; if (Path.GetExtension(file.Path) == ".m3u") playlist = new M3U(); else playlist = new PLS(); await playlist.LoadPlaylist(file).ConfigureAwait(false); } }
//TODO: Implement dual threaded downloading for multithreading. //TODO: Implement searching method and caching of json anime list. public override bool Download(string path, bool mt, bool continuos) { List <Episode> episodes = info.episodes; if (ao.vRange) { episodes = new List <Episode>(); for (int idx = ao.VideoRange[0]; idx < ao.VideoRange[1]; idx++) { episodes.Add(info.episodes[idx]); } } for (int idx = 0; idx < episodes.Count; idx++) { string source = Encoding.UTF8.GetString(M3U.DecryptAES128(Convert.FromBase64String(info.episodes[idx].source), KEY, null, new byte[8], 256)); source = Uri.EscapeUriString(source); downloadVideo("https://cdn.twist.moe" + source, idx); } return(true); }
public void LoadM3u(string FilePath) { if (Path.GetExtension(FilePath).ToLower() != ".m3u") { return; } //ClearList(); string[] L = M3U.Load(FilePath); var fpath = FilePath.Replace("\\m3u.m3u", "\\"); foreach (string st in L) { if (st == String.Empty) { break; } string path = fpath + st; AddNewFile(path); } }
private void _btnCopy_Click(object sender, EventArgs e) { //получаем из m3u список файлов M3U m3uFile = new M3U(fileAddress); //копируем файлы из списка по адресу String musicFileAddress = m3uFile.GetNextFilePath(); while (musicFileAddress != null) { FileInfo fileInfo = new FileInfo(musicFileAddress); try { File.Copy(musicFileAddress, folderAddress + @"\" + fileInfo.Name); } catch (Exception exception) { } musicFileAddress = m3uFile.GetNextFilePath(); } }
public static async Task <bool> SavePlaylist(Playlist playlist, IEnumerable <Mediafile> songs) { bool saved = false; FileSavePicker picker = new FileSavePicker(); picker.FileTypeChoices.Add("PLS Playlists", new List <string> { ".pls" }); picker.FileTypeChoices.Add("M3U Playlists", new List <string> { ".m3u" }); picker.SuggestedStartLocation = PickerLocationId.ComputerFolder; picker.SuggestedFileName = playlist.Name; await BreadDispatcher.InvokeAsync(async() => { var file = await picker.PickSaveFileAsync(); if (file != null) { IPlaylist sPlaylist = null; switch (file.FileType.ToLower()) { case ".m3u": sPlaylist = new M3U(); break; case ".pls": sPlaylist = new Pls(); break; } saved = await sPlaylist.SavePlaylist(songs, await file.OpenStreamForWriteAsync().ConfigureAwait(false)).ConfigureAwait(false); } }); return(saved); }
public void HeaderWithParametersTest() { var m3u = M3U.Parse(Sample.header_with_parameters); Assert.AreEqual(m3u.Attributes.Cache, 500); }
private bool DownloadVidstream(HentaiVideo video) { if (ao.stream) { startStreamServer(); } WebClient webC = new WebClient(); webC.Headers = headersCollection; if (video.slug.IsMp4() == true) { M3UMP4_SETTINGS m3set = new M3UMP4_SETTINGS { Host = string.Empty, Headers = headersCollection, Referer = string.Empty }; headersCollection.Add("Accept-Encoding", "gzip, deflate, br"); if (File.Exists($"{downloadTo}\\{video.name}.mp4")) { m3set.location = File.ReadAllBytes($"{downloadTo}\\{video.name}.mp4").Length; } M3U m3 = new M3U(video.slug, null, null, true, m3set); int l = m3.Size; double prg = (double)m3.location / (double)l; Byte[] b; while ((b = m3.getNext()) != null) { if (ao.stream) { publishToStream(b); } updateStatus?.Invoke(taskIndex, $"{video.name} {Strings.calculateProgress('#', m3.location, l)}"); mergeToMain($"{downloadTo}{Path.DirectorySeparatorChar}{video.name}.mp4", b); } return(true); } else { MatchCollection mc = Regex.Matches(webC.DownloadString(video.slug), @"(sub\..*?\..*?\.m3u8)|(ep\..*?\..*?\.m3u8)"); video.slug = $"{video.slug.TrimToSlash()}{GetHighestRes(mc.GetEnumerator())}"; if (ao.c && File.Exists($"{downloadTo}\\{video.name}.mp4")) { return(true); } M3U m3 = new M3U(webC.DownloadString(video.slug), headersCollection, video.slug.TrimToSlash()); int l = m3.Size; double prg = (double)m3.location / (double)l; Byte[] b; while ((b = m3.getNext()) != null) { if (ao.stream) { publishToStream(b); } updateStatus?.Invoke(taskIndex, $"{video.name} {Strings.calculateProgress('#', m3.location, l)}"); mergeToMain($"{downloadTo}{Path.DirectorySeparatorChar}{video.name}.mp4", b); } } return(true); }
public override bool Download(string path, bool mt, bool continuos) { GetDownloadUri(videoInfo == null ? new HentaiVideo { slug = path } : videoInfo.hentai_video); if (!ao.l) { downloadTo = $"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}HAnime{Path.DirectorySeparatorChar}{videoInfo.hentai_video.name.TrimIntegrals()}{Path.DirectorySeparatorChar}"; } else if (ao.android) { downloadTo = Path.Combine(ao.export, "HAnime", videoInfo.hentai_video.name.TrimIntegrals()); } else { downloadTo = Path.Combine(ao.export, videoInfo.hentai_video.brand); } Directory.CreateDirectory(downloadTo); M3U m3 = new M3U(webClient.DownloadString(rootObj.linkToManifest)); Byte[] b; int l = m3.Size; double prg; updateStatus?.Invoke(taskIndex, $"Beginning download of {videoInfo.hentai_video.name}"); ADLUpdates.CallLogUpdate($"Beginning download of {videoInfo.hentai_video.name}"); if (ao.stream) { startStreamServer(); while ((b = m3.getNext()) != null) { if (allStop) { invoker(); return(false); } updateStatus?.Invoke(taskIndex, $"{videoInfo.hentai_video.name} {Strings.calculateProgress('#', m3.location, l)}"); ADLUpdates.CallLogUpdate($"{videoInfo.hentai_video.name} {Strings.calculateProgress('#', m3.location, l)}"); publishToStream(b); mergeToMain(downloadTo + Path.DirectorySeparatorChar + videoInfo.hentai_video.name + ".mp4", b); } } else { while ((b = m3.getNext()) != null) { if (allStop) { invoker(); return(false); } prg = (double)m3.location / (double)l; updateStatus?.Invoke(taskIndex, $"{videoInfo.hentai_video.name} {Strings.calculateProgress('#', m3.location, l)}"); ADLUpdates.CallLogUpdate($"{videoInfo.hentai_video.name} {Strings.calculateProgress('#', m3.location, l)}"); mergeToMain(downloadTo + Path.DirectorySeparatorChar + videoInfo.hentai_video.name + ".mp4", b); } } if (continuos && videoInfo.next_hentai_video.name.RemoveSpecialCharacters().TrimIntegrals() == videoInfo.hentai_video.name.TrimIntegrals()) { HAnime h = new HAnime(new argumentList { term = $"https://hanime.tv/videos/hentai/{videoInfo.next_hentai_video.slug}", mt = mt, export = downloadTo, cc = continuos }, taskIndex, updateStatus); h.Begin(); } return(true); }
public void SaveCredentials(string fileName) { rawUsername = UTF8Encoding.UTF8.GetBytes(Username); rawPassword = UTF8Encoding.UTF8.GetBytes(Password); Byte[] key = new byte[16]; Byte[] iv = new byte[16]; Byte[][] kp = new byte[2][]; FillByteArray(ref key); kp[0] = key; FillByteArray(ref iv); Byte[] username = M3U.EncryptAES128(rawUsername, key, iv, 128, 128, PaddingMode.PKCS7); Byte[] ivUserPair = new byte[username.Length + iv.Length]; Array.Copy(username, 0, ivUserPair, 0, username.Length); Array.Copy(iv, 0, ivUserPair, username.Length, iv.Length); key = new byte[16]; iv = new byte[16]; FillByteArray(ref key); kp[1] = key; FillByteArray(ref iv); Byte[] password = M3U.EncryptAES128(rawPassword, key, iv, 128, 128, PaddingMode.PKCS7); Byte[] ivPswdPair = new byte[password.Length + iv.Length]; Array.Copy(password, 0, ivPswdPair, 0, password.Length); Array.Copy(iv, 0, ivPswdPair, password.Length, iv.Length); ZipArchiveEntry id = mode == ZipArchiveMode.Update ? integrationArchive.GetEntry($"{integrationID}.int") : integrationArchive.CreateEntry($"{integrationID}.int"); if (id == null) { id = integrationArchive.CreateEntry($"{integrationID}.int"); } else if (id != null && mode == ZipArchiveMode.Update) { id.Delete(); id = integrationArchive.CreateEntry($"{integrationID}.int"); } using (StreamWriter sw = new StreamWriter(id.Open())) sw.Write($"{Convert.ToBase64String(ivUserPair)}:{Convert.ToBase64String(ivPswdPair)}"); id = mode == ZipArchiveMode.Update ? integrationArchive.GetEntry($"ikey.bin") : integrationArchive.CreateEntry($"ikey.bin"); System.IO.Stream keyStream; string[] lines = new string[0]; if (id == null) { id = integrationArchive.CreateEntry($"ikey.bin"); } else if (id != null && mode == ZipArchiveMode.Update) { keyStream = id.Open(); if (keyStream.CanRead) { using (StreamReader sr = new StreamReader(keyStream)) lines = sr.ReadToEnd().Split("\n"); } id.Delete(); id = integrationArchive.CreateEntry($"ikey.bin"); } keyStream = id.Open(); if (lines.Length > 0) { setKeys(lines, kp); } else { lines = new string[1] { $"{integrationID}:{Convert.ToBase64String(kp[0])}:{Convert.ToBase64String(kp[1])}\n" } }; using (StreamWriter sw = new StreamWriter(keyStream)) foreach (string l in lines) { sw.Write(l + "\n"); } integrationArchive.Dispose(); }
public async Task <Extm3u> GetChannelM3U(bool reload = false) { return(_m3u ??= await M3U.ParseFromUrlAsync($"http://{_config.AnyseeIp}/n7_tv_chlist.m3u")); }