Skip to content

Commit 12b719b

Browse files
committed
fix megapeer
1 parent 88fa9d2 commit 12b719b

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

Controllers/CRON/MegapeerController.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,14 @@ async public Task<string> UpdateTasksParse()
8080
continue;
8181

8282
// Максимальное количиство страниц
83-
int.TryParse(Regex.Match(html, ">Всего: ([0-9]+)</td>").Groups[1].Value, out int maxpages);
83+
int.TryParse(Regex.Match(html, ">Всего: ([0-9]+)").Groups[1].Value, out int maxpages);
8484
maxpages = maxpages / 50;
8585

8686
if (maxpages > 0)
8787
{
88+
if (maxpages > 10)
89+
maxpages = 10;
90+
8891
// Загружаем список страниц в список задач
8992
for (int page = 0; page < maxpages; page++)
9093
{
@@ -162,7 +165,7 @@ async Task<bool> parsePage(string cat, int page)
162165

163166
var torrents = new List<MegapeerDetails>();
164167

165-
foreach (string row in html.Split("class=\"tCenter hl-tr\"").Skip(1))
168+
foreach (string row in html.Split("class=\"table_fon\"").Skip(1))
166169
{
167170
#region Локальный метод - Match
168171
string Match(string pattern, int index = 1)
@@ -174,21 +177,24 @@ string Match(string pattern, int index = 1)
174177
#endregion
175178

176179
#region createTime
177-
DateTime createTime = tParse.ParseCreateTime(Match("<span>Добавлен:</span> ([0-9]+ [^ ]+ [0-9]+)"), "dd.MM.yyyy");
180+
DateTime createTime = tParse.ParseCreateTime(Match("<td>([0-9]+ [^ ]+ [0-9]+)</td><td>"), "dd.MM.yy");
178181
if (createTime == default)
179182
continue;
180183
#endregion
181184

182185
#region Данные раздачи
183-
string url = Match("href=\"/(torrent/[0-9]+)\"");
184-
string title = Match("class=\"med tLink hl-tags bold\" [^>]+>([^\n\r]+)</a>");
185-
title = Regex.Replace(title, "<[^>]+>", "");
186+
string url = Match("href=\"/(torrent/[0-9]+)");
187+
string title = Match("class=\"url\">([^<]+)</a></td>");
188+
//title = Regex.Replace(title, "<[^>]+>", "");
186189

187-
string sizeName = Match("href=\"download/[0-9]+\">([\n\r\t ]+)?([^<\n\r]+)<", 2).Trim();
190+
string sizeName = Match("<td align=\"right\">([^<\n\r]+)", 1).Trim();
188191

189192
if (string.IsNullOrWhiteSpace(title))
190193
continue;
191194

195+
string _sid = Match("alt=\"S\"><font [^>]+>([0-9]+)</font>", 1);
196+
string _pir = Match("alt=\"L\"><font [^>]+>([0-9]+)</font>", 1);
197+
192198
url = $"{AppInit.conf.Megapeer.host}/{url}";
193199
#endregion
194200

@@ -382,13 +388,17 @@ string Match(string pattern, int index = 1)
382388
if (string.IsNullOrWhiteSpace(downloadid))
383389
continue;
384390

391+
int.TryParse(_sid, out int sid);
392+
int.TryParse(_pir, out int pir);
393+
385394
torrents.Add(new MegapeerDetails()
386395
{
387396
trackerName = "megapeer",
388397
types = types,
389398
url = url,
390399
title = title,
391-
sid = 1,
400+
sid = sid,
401+
pir = pir,
392402
sizeName = sizeName,
393403
createTime = createTime,
394404
name = name,

0 commit comments

Comments
 (0)