/* * Default landing page * * @variables: tempArray, _Items[]- used to gather an ID for featured items from OsrsBox API * arrFeatItems, RootobjectOsrsGe[]- used to gather GE price of items from OSRS GE API * * * * @returns: RootobjectOsrsGe[] arrFeatItems, used to find GE price of items */ public ViewResult Index() { var url = string.Empty; List <string> featItems = new List <string>() { "Abyssal whip", "Elder maul", "Twisted bow", }; _Items[] tempArray = new _Items[featItems.Count()]; for (int i = 0; i < featItems.Count(); i++) { url = "https://api.osrsbox.com/items?where={ \"name\": \"" + featItems[i] + "\", \"duplicate\": false }"; tempArray[i] = DownloadedItem.Download_serialized_json_data(url); } RootobjectOsrsGe[] arrFeatItems = new RootobjectOsrsGe[featItems.Count()]; for (int i = 0; i < featItems.Count(); i++) { url = "https://secure.runescape.com/m=itemdb_oldschool/api/catalogue/detail.json?item=" + tempArray[i].id; arrFeatItems[i] = DownloadedItemOsrsGe.Download_serialized_json_data(url); } return(View(arrFeatItems)); }
/// <summary> /// 获取所有的下载完成数据 /// </summary> /// <returns></returns> public List <DownloadedItem> GetDownloaded() { // 从数据库获取数据 DownloadedDb downloadedDb = new DownloadedDb(); Dictionary <string, object> dic = downloadedDb.QueryAll(); //downloadedDb.Close(); // 遍历 List <DownloadedItem> list = new List <DownloadedItem>(); foreach (KeyValuePair <string, object> item in dic) { if (item.Value is Downloaded downloaded) { DownloadedItem downloadedItem = new DownloadedItem { DownloadBase = GetDownloadBase(item.Key), Downloaded = downloaded }; if (downloadedItem.DownloadBase == null) { continue; } list.Add(downloadedItem); } } return(list); }
internal static void ExtractTexturePack(Game game, DownloadedItem item) { if (item.Data != null) { game.World.TextureUrl = item.Url; byte[] data = (byte[])item.Data; TexturePackExtractor extractor = new TexturePackExtractor(); using (Stream ms = new MemoryStream(data)) { extractor.Extract(ms, game); } TextureCache.Add(item.Url, data); TextureCache.AddETag(item.Url, item.ETag, game.ETags); TextureCache.AdddLastModified(item.Url, item.LastModified, game.LastModified); } else { FileStream data = TextureCache.GetStream(item.Url); if (data == null) // e.g. 404 errors { ExtractDefault(game); } else if (item.Url != game.World.TextureUrl) { game.World.TextureUrl = item.Url; TexturePackExtractor extractor = new TexturePackExtractor(); extractor.Extract(data, game); } } }
/* * Pulls a users favorite items from the database * and displays a table for them to view the * items that they favorited * */ public ViewResult MyFavorites() { List <FavoriteModel> favorites = repository.Items.Where(i => i.Username == HttpContext.User.Identity.Name).Distinct().ToList(); var url = string.Empty; RootobjectOsrsGe[] favoritesArr = new RootobjectOsrsGe[favorites.Count()]; for (int i = 0; i < favorites.Count(); i++) { url = "https://secure.runescape.com/m=itemdb_oldschool/api/catalogue/detail.json?item=" + favorites[i].ItemID; favoritesArr[i] = DownloadedItemOsrsGe.Download_serialized_json_data(url); } _Items[] itemFavorites = new _Items[favorites.Count()]; for (int i = 0; i < favorites.Count(); i++) { url = "https://api.osrsbox.com/items?where={ \"name\": \"" + favoritesArr[i].item.name + "\", \"duplicate\": false }"; itemFavorites[i] = DownloadedItem.Download_serialized_json_data(url); itemFavorites[i].price = favoritesArr[i].item.current.price; } TempData["Username"] = HttpContext.User.Identity.Name; TempData["Favorite"] = "true"; return(View("MyFavorites", itemFavorites)); }
/* * Action that allows a user to save an item * to view later on the MyFavorites page * */ public IActionResult SaveItem(RootobjectOsrsGe items, string returnUrl) { var url = "https://api.osrsbox.com/items?where={ \"name\": \"" + items.item.name + "\", \"duplicate\": false }"; _Items nameToId = new _Items(); nameToId = DownloadedItem.Download_serialized_json_data(url); url = "https://secure.runescape.com/m=itemdb_oldschool/api/catalogue/detail.json?item=" + nameToId.id; RootobjectOsrsGe itemID = new RootobjectOsrsGe(); itemID = DownloadedItemOsrsGe.Download_serialized_json_data(url); FavoriteModel favorite = new FavoriteModel { ItemID = itemID.item.id.ToString(), Username = HttpContext.User.Identity.Name }; if (repository.SaveFavorite(favorite) == 1) { TempData["Result"] = "Item successfully added to favorites"; return(Redirect(returnUrl)); } else if (repository.SaveFavorite(favorite) == 0) { TempData["Result"] = "This item is already in your favorites"; return(Redirect(returnUrl)); } else { TempData["Result"] = "Something went wrong with adding this item"; return(Redirect(returnUrl)); } }
internal static void ExtractTerrainPng(Game game, DownloadedItem item) { if (item.Data != null) { Bitmap bmp = (Bitmap)item.Data; game.World.TextureUrl = item.Url; game.Events.RaiseTexturePackChanged(); if (!Platform.Is32Bpp(bmp)) { Utils.LogDebug("Converting terrain atlas to 32bpp image"); game.Drawer2D.ConvertTo32Bpp(ref bmp); } if (!game.ChangeTerrainAtlas(bmp, null)) { bmp.Dispose(); return; } TextureCache.Add(item.Url, bmp); TextureCache.AddETag(item.Url, item.ETag, game.ETags); TextureCache.AdddLastModified(item.Url, item.LastModified, game.LastModified); } else { FileStream data = TextureCache.GetStream(item.Url); if (data == null) // e.g. 404 errors { ExtractDefault(game); } else if (item.Url != game.World.TextureUrl) { Bitmap bmp = GetBitmap(data); if (bmp == null) { data.Dispose(); return; } game.World.TextureUrl = item.Url; game.Events.RaiseTexturePackChanged(); if (game.ChangeTerrainAtlas(bmp, data)) { return; } bmp.Dispose(); data.Dispose(); } else { data.Dispose(); } } }
/* * Populates an instance of the _Items[] class * with predefined items to be gathered from the api * gathered from the Categories class * * Every action in this controller uses the same logic * * * @returns: _Items[] Des Weapons, data gathered from API */ public ViewResult Weapons() { var url = string.Empty; _Items[] DesWeapons = new _Items[Categories.Weapons.Count]; for (int i = 0; i < Categories.Weapons.Count(); i++) { url = "https://api.osrsbox.com/items?where={ \"name\": \"" + Categories.Weapons[i] + "\", \"duplicate\": false }"; DesWeapons[i] = DownloadedItem.Download_serialized_json_data(url); } TempData["Category"] = "Weapons"; return(View("Categories", DesWeapons)); }
/// <summary> /// 修改下载完成数据 /// </summary> /// <param name="downloadedItem"></param> public void UpdateDownloaded(DownloadedItem downloadedItem) { if (downloadedItem == null || downloadedItem.DownloadBase == null) { return; } UpdateDownloadBase(downloadedItem.DownloadBase); DownloadedDb downloadedDb = new DownloadedDb(); downloadedDb.Update(downloadedItem.DownloadBase.Uuid, downloadedItem.Downloaded); //downloadedDb.Close(); }
/// <summary> /// 删除下载完成数据 /// </summary> /// <param name="downloadedItem"></param> public void RemoveDownloaded(DownloadedItem downloadedItem) { if (downloadedItem == null || downloadedItem.DownloadBase == null) { return; } RemoveDownloadBase(downloadedItem.DownloadBase.Uuid); DownloadedDb downloadedDb = new DownloadedDb(); downloadedDb.Delete(downloadedItem.DownloadBase.Uuid); //downloadedDb.Close(); }
/// <summary> /// 添加下载完成数据 /// </summary> /// <param name="downloadedItem"></param> public void AddDownloaded(DownloadedItem downloadedItem) { if (downloadedItem == null || downloadedItem.DownloadBase == null) { return; } AddDownloadBase(downloadedItem.DownloadBase); DownloadedDb downloadedDb = new DownloadedDb(); object obj = downloadedDb.QueryById(downloadedItem.DownloadBase.Uuid); if (obj == null) { downloadedDb.Insert(downloadedItem.DownloadBase.Uuid, downloadedItem.Downloaded); } //downloadedDb.Close(); }
public ViewResult Food() { var url = string.Empty; List <_Items> DesFood = new List <_Items>(); for (int i = 0; i < Categories.Food.Count(); i++) { url = "https://api.osrsbox.com/items?where={ \"name\": \"" + Categories.Food[i] + "\", \"duplicate\": false }"; DesFood.Add(DownloadedItem.Download_serialized_json_data(url)); } TempData["Category"] = "Food"; _Items[] food = new _Items[Categories.Potions.Count()]; food = DesFood.ToArray(); return(View("Categories", food)); }
internal static void ExtractTexturePack(Game game, DownloadedItem item) { if (item.Data == null) { return; } game.World.TextureUrl = item.Url; byte[] data = (byte[])item.Data; TextureCache.Add(item.Url, data); TextureCache.AddETag(item.Url, item.ETag, game.ETags); TextureCache.AdddLastModified(item.Url, item.LastModified, game.LastModified); TexturePack extractor = new TexturePack(); using (Stream ms = new MemoryStream(data)) { extractor.Extract(ms, game); } }
public IActionResult NameFilter(int id) { var url = string.Empty; List <FavoriteModel> favorites = repository.Items.Where(i => i.Username == HttpContext.User.Identity.Name).Distinct().ToList(); RootobjectOsrsGe[] favoritesArr = new RootobjectOsrsGe[favorites.Count()]; for (int i = 0; i < favorites.Count; i++) { url = "https://secure.runescape.com/m=itemdb_oldschool/api/catalogue/detail.json?item=" + favorites[i].ItemID; favoritesArr[i] = (DownloadedItemOsrsGe.Download_serialized_json_data(url)); } _Items[] names = new _Items[favorites.Count()]; for (int i = 0; i < favorites.Count; i++) { url = "https://api.osrsbox.com/items?where={ \"name\": \"" + favoritesArr[i].item.name + "\", \"duplicate\": false }"; names[i] = (DownloadedItem.Download_serialized_json_data(url)); names[i].price = favoritesArr[i].item.current.price; } List <_Items> sortedList = names.OrderBy(p => p.name).ToList(); _Items[] sortedName = new _Items[favorites.Count()]; sortedName = sortedList.ToArray(); TempData["Username"] = HttpContext.User.Identity.Name; if (TempData["Sorted"] == null || TempData["Sorted"].Equals("high")) { sortedName = new _Items[favorites.Count()]; sortedName = sortedList.ToArray(); TempData["Sorted"] = "low"; return(View("MyFavorites", sortedName)); } else { sortedList.Reverse(); TempData["Sorted"] = "high"; sortedName = new _Items[Categories.Potions.Count()]; sortedName = sortedList.ToArray(); return(View("MyFavorites", sortedName)); } }
internal static void ExtractTerrainPng(Game game, DownloadedItem item) { if (item.Data == null) { return; } game.World.TextureUrl = item.Url; game.Events.RaiseTexturePackChanged(); Bitmap bmp = (Bitmap)item.Data; TextureCache.Add(item.Url, bmp); TextureCache.AddETag(item.Url, item.ETag, game.ETags); TextureCache.AdddLastModified(item.Url, item.LastModified, game.LastModified); if (!game.ChangeTerrainAtlas(bmp, null)) { bmp.Dispose(); } }
/* * Formats the search to input into OSRSBox Api * * @variables: searchedItems, _Items- used to gather the ID from the OSRSBox api to pass to 2nd API * specificItem, RootobjectOsrsGe- used to gather GE information from the OSRS GE API * */ public IActionResult SingleItem(Items item) { item.Name = item.Name.ToLower(); item.Name = char.ToUpper(item.Name[0]) + item.Name.Substring(1); ViewBag.ItemName = item.Name; RootobjectOsrsGe specificItem = new RootobjectOsrsGe(); var url = "https://api.osrsbox.com/items?where={ \"name\": \"" + item.Name + "\", \"duplicate\": false }&max_results=1"; _Items searchedItems = new _Items(); searchedItems = DownloadedItem.Download_serialized_json_data(url); if (searchedItems.id != null) { url = "https://secure.runescape.com/m=itemdb_oldschool/api/catalogue/detail.json?item=" + searchedItems.id; specificItem = DownloadedItemOsrsGe.Download_serialized_json_data(url); return(View(specificItem)); } else { TempData["Error"] = "Please enter a valid item name"; return(RedirectToAction("Stocks", "Home")); } }
private void DownloadFileFTP(string ftpURL, string fileDestinationPath, DownloadedItem item) { AppendLog("Downloading from " + ftpURL + " to " + fileDestinationPath); using (WebClient request = new WebClient()) { request.Credentials = new NetworkCredential("ftpuser", "mlcTech19!"); switch (item) { case DownloadedItem.VersionFile: { request.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadVersionFileCompleted); break; } case DownloadedItem.VersionManifest: { request.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadVersionManifestCompleted); break; } } request.DownloadFileAsync(new Uri(ftpURL), fileDestinationPath); } }
/// <summary> /// 下载一个视频 /// </summary> /// <param name="downloading"></param> /// <returns></returns> private async Task SingleDownload(DownloadingItem downloading) { // 路径 downloading.DownloadBase.FilePath = downloading.DownloadBase.FilePath.Replace("\\", "/"); string[] temp = downloading.DownloadBase.FilePath.Split('/'); //string path = downloading.DownloadBase.FilePath.Replace(temp[temp.Length - 1], ""); string path = downloading.DownloadBase.FilePath.TrimEnd(temp[temp.Length - 1].ToCharArray()); // 路径不存在则创建 if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } try { await Task.Run(new Action(() => { // 初始化 downloading.DownloadStatusTitle = string.Empty; downloading.DownloadContent = string.Empty; //downloading.Downloading.DownloadFiles.Clear(); // 解析并依次下载音频、视频、弹幕、字幕、封面等内容 Parse(downloading); // 暂停 Pause(downloading); string audioUid = null; // 如果需要下载音频 if (downloading.DownloadBase.NeedDownloadContent["downloadAudio"]) { //audioUid = DownloadAudio(downloading); for (int i = 0; i < retry; i++) { audioUid = DownloadAudio(downloading); if (audioUid != null && audioUid != nullMark) { break; } } } if (audioUid == nullMark) { DownloadFailed(downloading); return; } // 暂停 Pause(downloading); string videoUid = null; // 如果需要下载视频 if (downloading.DownloadBase.NeedDownloadContent["downloadVideo"]) { //videoUid = DownloadVideo(downloading); for (int i = 0; i < retry; i++) { videoUid = DownloadVideo(downloading); if (videoUid != null && videoUid != nullMark) { break; } } } if (videoUid == nullMark) { DownloadFailed(downloading); return; } // 暂停 Pause(downloading); string outputDanmaku = null; // 如果需要下载弹幕 if (downloading.DownloadBase.NeedDownloadContent["downloadDanmaku"]) { outputDanmaku = DownloadDanmaku(downloading); } // 暂停 Pause(downloading); List <string> outputSubtitles = null; // 如果需要下载字幕 if (downloading.DownloadBase.NeedDownloadContent["downloadSubtitle"]) { outputSubtitles = DownloadSubtitle(downloading); } // 暂停 Pause(downloading); string outputCover = null; string outputPageCover = null; // 如果需要下载封面 if (downloading.DownloadBase.NeedDownloadContent["downloadCover"]) { // page的封面 string pageCoverFileName = $"{downloading.DownloadBase.FilePath}.{GetImageExtension(downloading.DownloadBase.PageCoverUrl)}"; outputPageCover = DownloadCover(downloading, downloading.DownloadBase.PageCoverUrl, pageCoverFileName); string coverFileName = $"{downloading.DownloadBase.FilePath}.Cover.{GetImageExtension(downloading.DownloadBase.CoverUrl)}"; // 封面 //outputCover = DownloadCover(downloading, downloading.DownloadBase.CoverUrl, $"{path}/Cover.{GetImageExtension(downloading.DownloadBase.CoverUrl)}"); outputCover = DownloadCover(downloading, downloading.DownloadBase.CoverUrl, coverFileName); } // 暂停 Pause(downloading); // 混流 string outputMedia = string.Empty; if (downloading.DownloadBase.NeedDownloadContent["downloadAudio"] || downloading.DownloadBase.NeedDownloadContent["downloadVideo"]) { outputMedia = MixedFlow(downloading, audioUid, videoUid); } // 这里本来只有IsExist,没有pause,不知道怎么处理 // 是否存在 //isExist = IsExist(downloading); //if (!isExist.Result) //{ // return; //} // 检测音频、视频是否下载成功 bool isMediaSuccess = true; if (downloading.DownloadBase.NeedDownloadContent["downloadAudio"] || downloading.DownloadBase.NeedDownloadContent["downloadVideo"]) { // 只有下载音频不下载视频时才输出aac // 只要下载视频就输出mp4 if (File.Exists(outputMedia)) { // 成功 isMediaSuccess = true; } else { isMediaSuccess = false; } } // 检测弹幕是否下载成功 bool isDanmakuSuccess = true; if (downloading.DownloadBase.NeedDownloadContent["downloadDanmaku"]) { if (File.Exists(outputDanmaku)) { // 成功 isDanmakuSuccess = true; } else { isDanmakuSuccess = false; } } // 检测字幕是否下载成功 bool isSubtitleSuccess = true; if (downloading.DownloadBase.NeedDownloadContent["downloadSubtitle"]) { if (outputSubtitles == null) { // 为null时表示不存在字幕 } else { foreach (string subtitle in outputSubtitles) { if (!File.Exists(subtitle)) { // 如果有一个不存在则失败 isSubtitleSuccess = false; } } } } // 检测封面是否下载成功 bool isCover = true; if (downloading.DownloadBase.NeedDownloadContent["downloadCover"]) { if (File.Exists(outputCover) || File.Exists(outputPageCover)) { // 成功 isCover = true; } else { isCover = false; } } if (!isMediaSuccess || !isDanmakuSuccess || !isSubtitleSuccess || !isCover) { DownloadFailed(downloading); return; } // 下载完成后处理 Downloaded downloaded = new Downloaded { MaxSpeedDisplay = Format.FormatSpeed(downloading.Downloading.MaxSpeed), }; // 设置完成时间 downloaded.SetFinishedTimestamp(new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds()); DownloadedItem downloadedItem = new DownloadedItem { DownloadBase = downloading.DownloadBase, Downloaded = downloaded }; App.PropertyChangeAsync(new Action(() => { // 加入到下载完成list中,并从下载中list去除 downloadedList.Add(downloadedItem); downloadingList.Remove(downloading); // 下载完成列表排序 DownloadFinishedSort finishedSort = SettingsManager.GetInstance().GetDownloadFinishedSort(); App.SortDownloadedList(finishedSort); })); })); } catch (OperationCanceledException e) { Core.Utils.Debugging.Console.PrintLine(Tag, e.ToString()); LogManager.Debug(Tag, e.Message); } }
/* * Gathers the predefined item list from the categories * class based on which category is being sorted * * Sorts the items displayed by high alch value * */ public ViewResult HAFilter(int id) { var category = TempData["Category"]; switch (category) { case "Potions": var url = string.Empty; List <_Items> DesPotions = new List <_Items>(); for (int i = 0; i < Categories.Potions.Count(); i++) { url = "https://api.osrsbox.com/items?where={ \"name\": \"" + Categories.Potions[i] + "\", \"duplicate\": false }"; DesPotions.Add(DownloadedItem.Download_serialized_json_data(url)); } TempData["Category"] = "Potions"; List <_Items> sortedList = DesPotions.OrderBy(n => n.highalch).ToList(); if (TempData["Sorted"] == null || TempData["Sorted"].Equals("high")) { _Items[] desPotionsSortedHA = new _Items[Categories.Potions.Count()]; desPotionsSortedHA = sortedList.ToArray(); TempData["Sorted"] = "low"; return(View("Categories", desPotionsSortedHA)); } else { sortedList.Reverse(); TempData["Sorted"] = "high"; _Items[] desPotionsSortedHA = new _Items[Categories.Potions.Count()]; desPotionsSortedHA = sortedList.ToArray(); return(View("Categories", desPotionsSortedHA)); } case "Weapons": url = string.Empty; List <_Items> DesWeapons = new List <_Items>(); for (int i = 0; i < Categories.Weapons.Count(); i++) { url = "https://api.osrsbox.com/items?where={ \"name\": \"" + Categories.Weapons[i] + "\", \"duplicate\": false }"; DesWeapons.Add(DownloadedItem.Download_serialized_json_data(url)); } TempData["Category"] = "Weapons"; sortedList = DesWeapons.OrderBy(p => p.highalch).ToList(); if (TempData["Sorted"] == null || TempData["Sorted"].Equals("high")) { _Items[] desWeaponsSortedHA = new _Items[Categories.Potions.Count()]; desWeaponsSortedHA = sortedList.ToArray(); TempData["Sorted"] = "low"; return(View("Categories", desWeaponsSortedHA)); } else { sortedList.Reverse(); TempData["Sorted"] = "high"; _Items[] desWeaponsSortedHA = new _Items[Categories.Potions.Count()]; desWeaponsSortedHA = sortedList.ToArray(); return(View("Categories", desWeaponsSortedHA)); } case "Food": url = string.Empty; List <_Items> DesFood = new List <_Items>(); for (int i = 0; i < Categories.Food.Count(); i++) { url = "https://api.osrsbox.com/items?where={ \"name\": \"" + Categories.Food[i] + "\", \"duplicate\": false }"; DesFood.Add(DownloadedItem.Download_serialized_json_data(url)); } TempData["Category"] = "Food"; sortedList = DesFood.OrderBy(p => p.highalch).ToList(); if (TempData["Sorted"] == null || TempData["Sorted"].Equals("high")) { _Items[] desFoodSortedHA = new _Items[Categories.Potions.Count()]; desFoodSortedHA = sortedList.ToArray(); TempData["Sorted"] = "low"; return(View("Categories", desFoodSortedHA)); } else { sortedList.Reverse(); TempData["Sorted"] = "high"; _Items[] desFoodSortedHA = new _Items[Categories.Potions.Count()]; desFoodSortedHA = sortedList.ToArray(); return(View("Categories", desFoodSortedHA)); } case "Armor": url = string.Empty; List <_Items> DesArmor = new List <_Items>(); for (int i = 0; i < Categories.Armor.Count(); i++) { url = "https://api.osrsbox.com/items?where={ \"name\": \"" + Categories.Armor[i] + "\", \"duplicate\": false }"; DesArmor.Add(DownloadedItem.Download_serialized_json_data(url)); } TempData["Category"] = "Armor"; sortedList = DesArmor.OrderBy(p => p.highalch).ToList(); if (TempData["Sorted"] == null || TempData["Sorted"].Equals("high")) { _Items[] desArmorSortedHA = new _Items[Categories.Potions.Count()]; desArmorSortedHA = sortedList.ToArray(); TempData["Sorted"] = "low"; return(View("Categories", desArmorSortedHA)); } else { sortedList.Reverse(); TempData["Sorted"] = "high"; _Items[] desArmorSortedHA = new _Items[Categories.Potions.Count()]; desArmorSortedHA = sortedList.ToArray(); return(View("Categories", desArmorSortedHA)); } case "Woodcutting": url = string.Empty; List <_Items> DesWoodcutting = new List <_Items>(); for (int i = 0; i < Categories.Woodcutting.Count(); i++) { url = "https://api.osrsbox.com/items?where={ \"name\": \"" + Categories.Woodcutting[i] + "\", \"duplicate\": false }"; DesWoodcutting.Add(DownloadedItem.Download_serialized_json_data(url)); } TempData["Category"] = "Woodcutting"; sortedList = DesWoodcutting.OrderBy(p => p.highalch).ToList(); if (TempData["Sorted"] == null || TempData["Sorted"].Equals("high")) { _Items[] desWoodcuttingSortedHA = new _Items[Categories.Potions.Count()]; desWoodcuttingSortedHA = sortedList.ToArray(); TempData["Sorted"] = "low"; return(View("Categories", desWoodcuttingSortedHA)); } else { sortedList.Reverse(); TempData["Sorted"] = "high"; _Items[] desWoodcuttingSortedHA = new _Items[Categories.Potions.Count()]; desWoodcuttingSortedHA = sortedList.ToArray(); return(View("Categories", desWoodcuttingSortedHA)); } case "Mining": url = string.Empty; List <_Items> DesMining = new List <_Items>(); for (int i = 0; i < Categories.Mining.Count(); i++) { url = "https://api.osrsbox.com/items?where={ \"name\": \"" + Categories.Mining[i] + "\", \"duplicate\": false }"; DesMining.Add(DownloadedItem.Download_serialized_json_data(url)); } TempData["Category"] = "Mining"; sortedList = DesMining.OrderBy(p => p.highalch).ToList(); if (TempData["Sorted"] == null || TempData["Sorted"].Equals("high")) { _Items[] desMiningSortedHA = new _Items[Categories.Potions.Count()]; desMiningSortedHA = sortedList.ToArray(); TempData["Sorted"] = "low"; return(View("Categories", desMiningSortedHA)); } else { sortedList.Reverse(); TempData["Sorted"] = "high"; _Items[] desMiningSortedHA = new _Items[Categories.Potions.Count()]; desMiningSortedHA = sortedList.ToArray(); return(View("Categories", desMiningSortedHA)); } } return(View()); }
private void OpenPlayer(DownloadedItem data, int index = 0) { LocalPlayInfo localPlayInfo = new LocalPlayInfo(); localPlayInfo.Index = index; localPlayInfo.PlayInfos = new List <Controls.PlayInfo>(); foreach (var item in data.Epsidoes) { IDictionary <string, string> subtitles = new Dictionary <string, string>(); foreach (var subtitle in item.SubtitlePath) { subtitles.Add(subtitle.Name, subtitle.Url); } PlayUrlInfo info = new PlayUrlInfo(); if (item.IsDash) { info.mode = VideoPlayMode.Dash; info.dash_video_url = new DashItemModel() { baseUrl = item.Paths.FirstOrDefault(x => x.Contains("video.m4s")), base_url = item.Paths.FirstOrDefault(x => x.Contains("video.m4s")), }; info.dash_audio_url = new DashItemModel() { baseUrl = item.Paths.FirstOrDefault(x => x.Contains("audio.m4s")), base_url = item.Paths.FirstOrDefault(x => x.Contains("audio.m4s")), }; } else if (item.Paths.Count == 1) { info.mode = VideoPlayMode.SingleMp4; info.url = item.Paths[0]; } else { info.mode = VideoPlayMode.MultiFlv; info.multi_flv_url = new List <FlvDurlModel>(); foreach (var item2 in item.Paths.OrderBy(x => x)) { info.multi_flv_url.Add(new FlvDurlModel() { url = item2 }); } } localPlayInfo.PlayInfos.Add(new Controls.PlayInfo() { avid = item.AVID, cid = item.CID, ep_id = item.EpisodeID, play_mode = Controls.VideoPlayType.Download, season_id = data.IsSeason ? data.ID.ToInt32() : 0, order = item.Index, title = item.Title, season_type = 0, LocalPlayInfo = new Controls.LocalPlayInfo() { DanmakuPath = item.DanmakuPath, Quality = item.QualityName, Subtitles = subtitles, Info = info } }); } MessageCenter.OpenNewWindow(this, new NavigationInfo() { icon = Symbol.Play, page = typeof(LocalPlayerPage), parameters = localPlayInfo, title = data.Title }); }