//(t => t.RelationshipType == "enclosure"); //(t => t.RelationshipType == "alternate"); public static RssTorrent ToTorrent(this Rss.RssItem item) { RssTorrent rt = new RssTorrent(item.Guid.Name) { Name = item.Title, Summary = item.Description, TimePublished = item.PubDate, }; if (item.Enclosure != null) { if (item.Enclosure.Type == "application/x-bittorrent") { rt.TorrentFileUrl = item.Enclosure.Url.ToString(); } } else { string url = item.Link.ToString(); if (Utility.IsMagnetLink(url)) { rt.TorrentMagnetUrl = url; } else { // Warning: This URL might not be the .torrent file. (In case of https://animetosho.org) rt.TorrentFileUrl = url; } } return(rt); }
public bool IsAllowed(RssTorrent t) { if (this.FilterValid) { bool regex_match = this.m.IsMatch(t.Name); if (this.FilterAction == FilterActionEnum.Download) { return regex_match; } else //In Skip action, we don't want stuffs that match the filter { return !regex_match; } } return false; }
public bool IsAllowed(RssTorrent t) { if (this.FilterValid) { bool regex_match = this.m.IsMatch(t.Name); if (this.FilterAction == FilterActionEnum.Download) { return(regex_match); } else //In Skip action, we don't want stuffs that match the filter { return(!regex_match); } } return(false); }
private bool IsAllowed(RssTorrent t) { if (this.Filters.Count > 0) { for (int i = 0; i < this.Filters.Count; i++) { try { if (this.Filters[i].IsAllowed(t)) { return(true); } } catch (IndexOutOfRangeException) { break; } catch (Exception) { continue; } } return(false); } return(true); }
private static void Process_NewRssItems(RssUrlEntry entry, RssTorrent[] new_items) { foreach (var nitem in new_items) { if (url_404.Contains(nitem.TorrentFileUrl)) { continue; } string save_path = Path.Combine(RssTorrentsStorageDirectory, Utility.CleanFileName(nitem.Name) + ".torrent"); nitem.TorrentFilePath = save_path; if (File.Exists(save_path)) { //re-load from downloaded file App.Current.Dispatcher.Invoke(new Action(() => { nitem.LastResponseMessage = "Data was already saved"; nitem.LastResponseType = DownloadRssResponse.ResonseType.OK; nitem.Success = AppState.AddTorrentRss(save_path, entry); })); continue; } if (!IsQueued(nitem)) { QueuedItems.Add(nitem); System.Threading.Tasks.Task.Factory.StartNew(new Action(() => { Debug.WriteLine("[Rssdownloader-TQ]: Work Item '{0}' has been started", nitem.Name, ""); var res = download(nitem.IsMagnetOnly ? nitem.TorrentMagnetUrl : nitem.TorrentFileUrl); nitem.LastResponse = res; Debug.WriteLine("[Rssdownloader-TQ]: Work Item '{0}' resp type is {1}", nitem.Name, res.Type); if (res.Type == DownloadRssResponse.ResonseType.OK || res.Type == DownloadRssResponse.ResonseType.MagnetLink) { byte[] data = res.Data; if (data.Length > 0) { File.WriteAllBytes(save_path, data); Debug.WriteLine("[Rssdownloader-TQ]: Work Item '{0}' succesfully downloaded", nitem.Name, ""); App.Current.Dispatcher.Invoke(new Action(() => { nitem.Success = AppState.AddTorrentRss(save_path, entry); })); } else { if (res.Type == DownloadRssResponse.ResonseType.MagnetLink) { Debug.WriteLine("[Rssdownloader-TQ]: Cannot add torrent ({0}) magnet ('{1}')", nitem.Name, nitem.TorrentMagnetUrl); } //What should we do? } } else if (res.Type == DownloadRssResponse.ResonseType.NotFound) { if (!url_404.Contains(nitem.TorrentFileUrl)) { url_404.Add(nitem.TorrentFileUrl); Debug.WriteLine("[Rssdownloader-TQ]: URL '{0}' not found, therefore banned.", nitem.TorrentFileUrl, ""); } } QueuedItems.Remove(nitem); return; })); } } }
private static bool IsQueued(RssTorrent rt) { return QueuedItems.Contains(rt); }
//(t => t.RelationshipType == "enclosure"); //(t => t.RelationshipType == "alternate"); public static RssTorrent ToTorrent(this Rss.RssItem item) { RssTorrent rt = new RssTorrent(item.Guid.Name) { Name = item.Title, Summary = item.Description, TimePublished = item.PubDate, }; if (item.Enclosure != null) { if (item.Enclosure.Type == "application/x-bittorrent") { rt.TorrentFileUrl = item.Enclosure.Url.ToString(); } } else { string url = item.Link.ToString(); if (Utility.IsMagnetLink(url)) { rt.TorrentMagnetUrl = url; } else { // Warning: This URL might not be the .torrent file. (In case of https://animetosho.org) rt.TorrentFileUrl = url; } } return rt; }
private bool IsAllowed(RssTorrent t) { if (this.Filters.Count > 0) { for (int i = 0; i < this.Filters.Count; i++) { try { if (this.Filters[i].IsAllowed(t)) { return true; } } catch (IndexOutOfRangeException) { break; } catch (Exception) { continue; } } return false; } return true; }
private static bool IsQueued(RssTorrent rt) { return(QueuedItems.Contains(rt)); }