Private GIT
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SickRage-1
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
SickRage-1
Commits
c1663a11
Commit
c1663a11
authored
Jan 5, 2016
by
miigotu
Browse files
Options
Downloads
Patches
Plain Diff
Clean and simplify scenetime provider
parent
b598bd6b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sickbeard/providers/scenetime.py
+42
-42
42 additions, 42 deletions
sickbeard/providers/scenetime.py
with
42 additions
and
42 deletions
sickbeard/providers/scenetime.py
+
42
−
42
View file @
c1663a11
...
...
@@ -26,6 +26,8 @@ from sickbeard import tvcache
from
sickbeard.bs4_parser
import
BS4Parser
from
sickrage.providers.torrent.TorrentProvider
import
TorrentProvider
from
sickrage.helper.common
import
try_int
class
SceneTimeProvider
(
TorrentProvider
):
...
...
@@ -89,10 +91,11 @@ class SceneTimeProvider(TorrentProvider):
if
not
data
:
continue
try
:
with
BS4Parser
(
data
,
'
html5lib
'
)
as
html
:
torrent_table
=
html
.
select
(
"
#torrenttable table
"
)
torrent_rows
=
torrent_table
[
0
].
select
(
"
tr
"
)
if
torrent_table
else
[]
torrent_table
=
html
.
find
(
'
div
'
,
id
=
"
torrenttable
"
)
torrent_rows
=
[]
if
torrent_table
:
torrent_rows
=
torrent_table
.
select
(
"
tr
"
)
# Continue only if one Release is found
if
len
(
torrent_rows
)
<
2
:
...
...
@@ -102,26 +105,23 @@ class SceneTimeProvider(TorrentProvider):
# Scenetime apparently uses different number of cells in #torrenttable based
# on who you are. This works around that by extracting labels from the first
# <tr> and using their index to find the correct download/seeders/leechers td.
labels
=
[
label
.
get_text
()
for
label
in
torrent_rows
[
0
].
find_all
(
'
td
'
)]
labels
=
[
label
.
get_text
(
strip
=
True
)
for
label
in
torrent_rows
[
0
].
find_all
(
'
td
'
)]
for
result
in
torrent_rows
[
1
:]:
try
:
cells
=
result
.
find_all
(
'
td
'
)
link
=
cells
[
labels
.
index
(
'
Name
'
)].
find
(
'
a
'
)
torrent_id
=
link
[
'
href
'
].
replace
(
'
details.php?id=
'
,
''
).
split
(
"
&
"
)[
0
]
full_id
=
link
[
'
href
'
].
replace
(
'
details.php?id=
'
,
''
)
torrent_id
=
full_id
.
split
(
"
&
"
)[
0
]
try
:
title
=
link
.
contents
[
0
].
get_text
()
if
link
.
contents
[
0
].
get_text
()
else
None
filename
=
"
%s.torrent
"
%
title
.
replace
(
"
"
,
"
.
"
)
if
title
else
None
download_url
=
self
.
urls
[
'
download
'
]
%
(
torrent_id
,
filename
)
if
torrent_id
and
filename
else
None
title
=
link
.
get_text
(
strip
=
True
)
download_url
=
self
.
urls
[
'
download
'
]
%
(
torrent_id
,
"
%s.torrent
"
%
title
.
replace
(
"
"
,
"
.
"
))
seeders
=
int
(
cells
[
labels
.
index
(
'
Seeders
'
)].
get_text
(
))
if
cells
[
labels
.
index
(
'
Seeders
'
)].
get_text
()
else
1
leechers
=
int
(
cells
[
labels
.
index
(
'
Leechers
'
)].
get_text
(
))
if
cells
[
labels
.
index
(
'
Leechers
'
)].
get_text
()
else
0
size
=
self
.
_convertSize
(
cells
[
labels
.
index
(
'
Size
'
)].
get_text
(
))
if
cells
[
labels
.
index
(
'
Size
'
)].
get_text
()
else
-
1
seeders
=
try_
int
(
cells
[
labels
.
index
(
'
Seeders
'
)].
get_text
(
strip
=
True
))
leechers
=
try_
int
(
cells
[
labels
.
index
(
'
Leechers
'
)].
get_text
(
strip
=
True
))
size
=
self
.
_convertSize
(
cells
[
labels
.
index
(
'
Size
'
)].
get_text
(
strip
=
True
))
except
(
AttributeError
,
TypeError
):
except
(
AttributeError
,
TypeError
,
KeyError
,
ValueError
):
continue
if
not
all
([
title
,
download_url
]):
...
...
@@ -139,9 +139,6 @@ class SceneTimeProvider(TorrentProvider):
items
[
mode
].
append
(
item
)
except
Exception
as
e
:
logger
.
log
(
u
"
Failed parsing provider. Traceback: %s
"
%
traceback
.
format_exc
(),
logger
.
ERROR
)
# For each search mode sort all the items by seeders if available
items
[
mode
].
sort
(
key
=
lambda
tup
:
tup
[
3
],
reverse
=
True
)
...
...
@@ -152,10 +149,10 @@ class SceneTimeProvider(TorrentProvider):
def
seed_ratio
(
self
):
return
self
.
ratio
def
_convertSize
(
size
String
):
size
=
sizeString
[:
-
2
].
strip
()
modifier
=
sizeString
[
-
2
:
].
upper
()
@staticmethod
def
_convertSize
(
size
):
modifier
=
size
[
-
2
:
].
upper
()
size
=
size
[:
-
2
].
strip
()
try
:
size
=
float
(
size
)
if
modifier
in
'
KB
'
:
...
...
@@ -166,8 +163,11 @@ class SceneTimeProvider(TorrentProvider):
size
*=
1024
**
3
elif
modifier
in
'
TB
'
:
size
*=
1024
**
4
else
:
raise
except
Exception
:
size
=
-
1
return
long
(
size
)
class
SceneTimeCache
(
tvcache
.
TVCache
):
...
...
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