Private GIT
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
Jackett
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vlbox
Jackett
Commits
1f94dec0
Commit
1f94dec0
authored
Jan 19, 2016
by
flightlevel
Browse files
Options
Downloads
Plain Diff
Merge pull request #198 from flightlevel/speedcd
SpeedCd: Change API to parsing
parents
2901ccee
7b74f981
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Jackett/Indexers/SpeedCD.cs
+67
-33
67 additions, 33 deletions
src/Jackett/Indexers/SpeedCD.cs
with
67 additions
and
33 deletions
src/Jackett/Indexers/SpeedCD.cs
+
67
−
33
View file @
1f94dec0
...
@@ -8,18 +8,17 @@ using NLog;
...
@@ -8,18 +8,17 @@ using NLog;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Globalization
;
using
System.Globalization
;
using
System.
Text.RegularExpressions
;
using
System.
Linq
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Jackett.Models.IndexerConfig
;
using
Jackett.Models.IndexerConfig
;
using
System.Collections.Specialized
;
namespace
Jackett.Indexers
namespace
Jackett.Indexers
{
{
public
class
SpeedCD
:
BaseIndexer
,
IIndexer
public
class
SpeedCD
:
BaseIndexer
,
IIndexer
{
{
private
string
LoginUrl
{
get
{
return
SiteLink
+
"take.login.php"
;
}
}
private
string
LoginUrl
{
get
{
return
SiteLink
+
"take.login.php"
;
}
}
private
string
SearchUrl
{
get
{
return
SiteLink
+
"V3/API/API.php"
;
}
}
private
string
SearchUrl
{
get
{
return
SiteLink
+
"browse.php"
;
}
}
private
string
CommentsUrl
{
get
{
return
SiteLink
+
"t/{0}"
;
}
}
private
string
DownloadUrl
{
get
{
return
SiteLink
+
"download.php?torrent={0}"
;
}
}
new
ConfigurationDataBasicLogin
configData
new
ConfigurationDataBasicLogin
configData
{
{
...
@@ -30,7 +29,7 @@ namespace Jackett.Indexers
...
@@ -30,7 +29,7 @@ namespace Jackett.Indexers
public
SpeedCD
(
IIndexerManagerService
i
,
Logger
l
,
IWebClient
wc
,
IProtectionService
ps
)
public
SpeedCD
(
IIndexerManagerService
i
,
Logger
l
,
IWebClient
wc
,
IProtectionService
ps
)
:
base
(
name
:
"Speed.cd"
,
:
base
(
name
:
"Speed.cd"
,
description
:
"Your home now!"
,
description
:
"Your home now!"
,
link
:
"http://speed.cd/"
,
link
:
"http
s
://speed.cd/"
,
caps
:
new
TorznabCapabilities
(),
caps
:
new
TorznabCapabilities
(),
manager
:
i
,
manager
:
i
,
client
:
wc
,
client
:
wc
,
...
@@ -91,9 +90,7 @@ namespace Jackett.Indexers
...
@@ -91,9 +90,7 @@ namespace Jackett.Indexers
{
{
var
releases
=
new
List
<
ReleaseInfo
>();
var
releases
=
new
List
<
ReleaseInfo
>();
Dictionary
<
string
,
string
>
qParams
=
new
Dictionary
<
string
,
string
>();
NameValueCollection
qParams
=
new
NameValueCollection
();
qParams
.
Add
(
"jxt"
,
"4"
);
qParams
.
Add
(
"jxw"
,
"b"
);
if
(!
string
.
IsNullOrEmpty
(
query
.
SanitizedSearchTerm
))
if
(!
string
.
IsNullOrEmpty
(
query
.
SanitizedSearchTerm
))
{
{
...
@@ -106,39 +103,76 @@ namespace Jackett.Indexers
...
@@ -106,39 +103,76 @@ namespace Jackett.Indexers
qParams
.
Add
(
"c"
+
cat
,
"1"
);
qParams
.
Add
(
"c"
+
cat
,
"1"
);
}
}
var
response
=
await
PostDataWithCookiesAndRetry
(
SearchUrl
,
qParams
);
string
urlSearch
=
SearchUrl
;
if
(
qParams
.
Count
>
0
)
{
urlSearch
+=
$"?
{
qParams
.
GetQueryString
()}
"
;
}
var
response
=
await
RequestStringWithCookiesAndRetry
(
urlSearch
);
try
try
{
{
var
jsonResult
=
JObject
.
Parse
(
response
.
Content
);
var
resultArray
=
((
JArray
)
jsonResult
[
"Fs"
])[
0
][
"Cn"
][
"torrents"
];
CQ
dom
=
response
.
Content
;
foreach
(
var
jobj
in
resultArray
)
var
rows
=
dom
[
"div[id='torrentTable'] > div[class='box torrentBox'] > div[class='boxContent'] > table > tbody > tr"
];
foreach
(
IDomObject
row
in
rows
)
{
{
var
release
=
new
ReleaseInfo
();
CQ
torrentData
=
row
.
OuterHTML
;
CQ
cells
=
row
.
Cq
().
Find
(
"td"
);
var
id
=
(
int
)
jobj
[
"id"
]
;
string
title
=
torrentData
.
Find
(
"a[class='torrent']"
).
First
().
Text
().
Trim
()
;
release
.
Comments
=
new
Uri
(
string
.
Format
(
CommentsUrl
,
id
));
Uri
link
=
new
Uri
(
SiteLink
+
torrentData
.
Find
(
"img[class='icos save']"
).
First
().
Parent
().
Attr
(
"href"
).
Trim
(
));
release
.
Guid
=
release
.
Comments
;
Uri
guid
=
new
Uri
(
SiteLink
+
torrentData
.
Find
(
"a[class='torrent']"
).
First
().
Attr
(
"href"
).
Trim
().
TrimStart
(
'/'
))
;
release
.
Link
=
new
Uri
(
string
.
Format
(
DownloadUrl
,
id
)
);
long
size
=
ReleaseInfo
.
GetBytes
(
cells
.
Elements
.
ElementAt
(
4
).
InnerText
);
release
.
Title
=
Regex
.
Replace
((
string
)
jobj
[
"name"
],
"<.*?>"
,
String
.
Empty
);
int
seeders
=
0
;
if
(
cells
.
Elements
.
ElementAt
(
5
).
FirstChild
.
HasChildren
)
{
seeders
=
ParseUtil
.
CoerceInt
(
cells
.
Elements
.
ElementAt
(
5
).
FirstChild
.
InnerText
);
}
else
{
seeders
=
ParseUtil
.
CoerceInt
(
cells
.
Elements
.
ElementAt
(
5
).
InnerText
);
};
var
SizeStr
=
((
string
)
jobj
[
"size"
]);
int
leechers
=
0
;
release
.
Size
=
ReleaseInfo
.
GetBytes
(
SizeStr
);
if
(
cells
.
Elements
.
ElementAt
(
6
).
FirstChild
.
HasChildren
)
{
leechers
=
ParseUtil
.
CoerceInt
(
cells
.
Elements
.
ElementAt
(
6
).
FirstChild
.
InnerText
);
}
else
{
leechers
=
ParseUtil
.
CoerceInt
(
cells
.
Elements
.
ElementAt
(
6
).
InnerText
);
}
var
cat
=
(
int
)
jobj
[
"cat"
]
;
string
pubDateStr
=
torrentData
.
Find
(
"span[class^='elapsedDate']"
).
First
().
Attr
(
"title"
).
Trim
().
Replace
(
" at"
,
""
)
;
release
.
Category
=
MapTrackerCatToNewznab
(
cat
.
ToString
()
);
DateTime
publishDate
=
DateTime
.
ParseExact
(
pubDateStr
,
"dddd, MMMM d, yyyy h:mmtt"
,
CultureInfo
.
InvariantCulture
,
DateTimeStyles
.
AssumeUniversal
).
ToLocalTime
(
);
release
.
Seeders
=
ParseUtil
.
CoerceInt
((
string
)
jobj
[
"seed"
]);
long
category
=
0
;
release
.
Peers
=
ParseUtil
.
CoerceInt
((
string
)
jobj
[
"leech"
])
+
release
.
Seeders
;
string
cat
=
torrentData
.
Find
(
"a[class='cat']"
).
First
().
Attr
(
"id"
).
Trim
();
long
.
TryParse
(
cat
,
out
category
);
// ex: Tuesday, May 26, 2015 at 6:00pm
var
dateStr
=
new
Regex
(
"title=\"(.*?)\""
).
Match
((
string
)
jobj
[
"added"
]).
Groups
[
1
].
ToString
();
var
release
=
new
ReleaseInfo
();
dateStr
=
dateStr
.
Replace
(
" at"
,
""
);
var
dateTime
=
DateTime
.
ParseExact
(
dateStr
,
"dddd, MMMM d, yyyy h:mmtt"
,
CultureInfo
.
InvariantCulture
,
DateTimeStyles
.
AssumeUniversal
);
release
.
Title
=
title
;
release
.
PublishDate
=
dateTime
.
ToLocalTime
();
release
.
Guid
=
guid
;
release
.
Link
=
link
;
release
.
PublishDate
=
publishDate
;
release
.
Size
=
size
;
release
.
Description
=
release
.
Title
;
release
.
Seeders
=
seeders
;
release
.
Peers
=
seeders
+
leechers
;
release
.
MinimumRatio
=
1
;
release
.
MinimumSeedTime
=
172800
;
release
.
Category
=
MapTrackerCatToNewznab
(
category
.
ToString
());
release
.
Comments
=
guid
;
releases
.
Add
(
release
);
releases
.
Add
(
release
);
}
}
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment