Private GIT
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CouchPotatoServer
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
CouchPotatoServer
Commits
a56bbf0b
Commit
a56bbf0b
authored
12 years ago
by
Ruud
Browse files
Options
Downloads
Patches
Plain Diff
CP API cleanup
parent
4b54113f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
couchpotato/core/providers/movie/couchpotatoapi/main.py
+10
-38
10 additions, 38 deletions
couchpotato/core/providers/movie/couchpotatoapi/main.py
with
10 additions
and
38 deletions
couchpotato/core/providers/movie/couchpotatoapi/main.py
+
10
−
38
View file @
a56bbf0b
...
...
@@ -5,9 +5,7 @@ from couchpotato.core.helpers.request import jsonified, getParams
from
couchpotato.core.logger
import
CPLog
from
couchpotato.core.providers.movie.base
import
MovieProvider
from
couchpotato.core.settings.model
import
Movie
from
flask.helpers
import
json
import
time
import
traceback
log
=
CPLog
(
__name__
)
...
...
@@ -33,18 +31,7 @@ class CouchPotatoApi(MovieProvider):
addEvent
(
'
movie.is_movie
'
,
self
.
isMovie
)
def
search
(
self
,
q
,
limit
=
12
):
cache_key
=
'
cpapi.cache.%s
'
%
q
cached
=
self
.
getCache
(
cache_key
,
self
.
urls
[
'
search
'
]
%
tryUrlencode
(
q
),
headers
=
self
.
getRequestHeaders
())
if
cached
:
try
:
movies
=
json
.
loads
(
cached
)
return
movies
except
:
log
.
error
(
'
Failed parsing search results: %s
'
,
traceback
.
format_exc
())
return
[]
return
self
.
getJsonData
(
self
.
urls
[
'
search
'
]
%
tryUrlencode
(
q
),
headers
=
self
.
getRequestHeaders
())
def
isMovie
(
self
,
identifier
=
None
):
...
...
@@ -62,38 +49,23 @@ class CouchPotatoApi(MovieProvider):
if
not
identifier
:
return
cache_key
=
'
cpapi.cache.info.%s
'
%
identifier
cached
=
self
.
getCache
(
cache_key
,
self
.
urls
[
'
info
'
]
%
identifier
,
headers
=
self
.
getRequestHeaders
())
if
cached
:
try
:
movie
=
json
.
loads
(
cached
)
return
movie
except
:
log
.
error
(
'
Failed parsing info results: %s
'
,
traceback
.
format_exc
())
result
=
self
.
getJsonData
(
self
.
urls
[
'
info
'
]
%
identifier
,
headers
=
self
.
getRequestHeaders
())
if
result
:
return
result
return
{}
def
getReleaseDate
(
self
,
identifier
=
None
):
if
identifier
is
None
:
return
{}
try
:
data
=
self
.
urlopen
(
self
.
urls
[
'
eta
'
]
%
identifier
,
headers
=
self
.
getRequestHeaders
())
dates
=
json
.
loads
(
data
)
dates
=
self
.
getJsonData
(
self
.
urls
[
'
eta
'
]
%
identifier
,
headers
=
self
.
getRequestHeaders
())
log
.
debug
(
'
Found ETA for %s: %s
'
,
(
identifier
,
dates
))
return
dates
except
Exception
,
e
:
log
.
error
(
'
Error getting ETA for %s: %s
'
,
(
identifier
,
e
))
return
{}
return
dates
def
suggest
(
self
,
movies
=
[],
ignore
=
[]):
try
:
data
=
self
.
urlopen
(
self
.
urls
[
'
suggest
'
]
%
(
'
,
'
.
join
(
movies
),
'
,
'
.
join
(
ignore
)))
suggestions
=
json
.
loads
(
data
)
suggestions
=
self
.
getJsonData
(
self
.
urls
[
'
suggest
'
]
%
(
'
,
'
.
join
(
movies
),
'
,
'
.
join
(
ignore
)))
log
.
info
(
'
Found Suggestions for %s
'
,
(
suggestions
))
except
Exception
,
e
:
log
.
error
(
'
Error getting suggestions for %s: %s
'
,
(
movies
,
e
))
return
suggestions
...
...
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