Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MediaDBPythonScripte
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
8
Issues
8
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
BA_SI-Projekt
MediaDBPythonScripte
Commits
3430fb8a
Commit
3430fb8a
authored
Feb 20, 2016
by
Nico Schallehn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
62b35308
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
42 deletions
+66
-42
media.class.php
media.class.php
+66
-42
No files found.
media.class.php
View file @
3430fb8a
...
...
@@ -229,47 +229,8 @@ class Media {
echo
" done!"
.
PHP_EOL
;
$newData
[
"fsk"
]
=
$this
->
gibFSK
(
$imdb
,
$fehler
);
echo
" Hole Daten von themoviedb.org... "
;
$tmdbKey
=
"b1ddcc7d16281ce09f692896f882ba9d"
;
//$this->config['API_Keys']['Tmdb_Key']
$tmdb
=
json_decode
(
file_get_contents
(
"https://api.themoviedb.org/3/find/tt"
.
$Film
[
"imdbID"
]
.
"?external_source=imdb_id&api_key="
.
$tmdbKey
.
"&language=de"
),
true
);
if
(
isset
(
$tmdb
[
"movie_results"
])){
if
(
isset
(
$tmdb
[
"movie_results"
][
0
][
"overview"
])){
echo
" done!"
.
PHP_EOL
;
$newData
[
"summary"
]
=
$tmdb
[
"movie_results"
][
0
][
"overview"
];
}
else
{
echo
" fail2!"
.
PHP_EOL
;
$fehler
.=
$this
->
Console
->
error
(
"keine summary gefunden für imdbID "
.
$Film
[
"imdbID"
]
.
"!"
)
.
PHP_EOL
;
}
$url2
=
"https://api.themoviedb.org/3/movie/"
.
$tmdb
[
"movie_results"
][
0
][
"id"
]
.
"?api_key="
.
$tmdbKey
.
"&language=de&append_to_response=trailers"
;
$tmdb2
=
json_decode
(
file_get_contents
(
$url2
),
true
);
if
(
isset
(
$tmdb2
[
"trailers"
][
"youtube"
][
0
][
"source"
])){
//TODO youtube Key auf 11 Zeichen prüfen!!
$youtubeID
=
str_replace
(
"&hd=1"
,
""
,
$tmdb2
[
"trailers"
][
"youtube"
][
0
][
"source"
]);
if
(
strpos
(
$youtubeID
,
"youtube"
)
>
0
){
echo
"doofer IFrame....!!!"
;
}
else
{
$newData
[
"youtube"
]
=
"DE:"
.
$youtubeID
;
}
$this
->
gibTMDBdata
(
$Film
[
"imdbID"
],
$newData
);
}
else
{
$url2
=
"https://api.themoviedb.org/3/movie/"
.
$tmdb
[
"movie_results"
][
0
][
"id"
]
.
"?api_key="
.
$tmdbKey
.
"&language=en&append_to_response=trailers"
;
$tmdb2
=
json_decode
(
file_get_contents
(
$url2
),
true
);
if
(
isset
(
$tmdb2
[
"trailers"
][
"youtube"
][
0
][
"source"
])){
$youtubeID
=
str_replace
(
"&hd=1"
,
""
,
$tmdb2
[
"trailers"
][
"youtube"
][
0
][
"source"
]);
if
(
strpos
(
$youtubeID
,
"youtube"
)
>
0
){
echo
"doofer IFrame....!!!"
;
}
else
{
$newData
[
"youtube"
]
=
"EN:"
.
$youtubeID
;
}
}
else
{
$fehler
.=
$this
->
Console
->
error
(
"kein Trailer gefunden für imdbID "
.
$Film
[
"imdbID"
]
.
"!"
)
.
PHP_EOL
;
}
}
}
else
{
echo
" fail1!"
.
PHP_EOL
;
}
$update
=
""
;
$first
=
true
;
...
...
@@ -317,6 +278,55 @@ class Media {
file_put_contents
(
"./phpTestout/update.txt"
,
$status
.
PHP_EOL
,
FILE_APPEND
);
}
}
/**
* @param imdbID
* @param DataArray
* @param
* @param
*/
private
function
gibTMDBdata
(
$imdbID
,
&
$DataArray
){
echo
" Hole Daten von themoviedb.org... "
;
$tmdbKey
=
"b1ddcc7d16281ce09f692896f882ba9d"
;
echo
"API KEY TMDB: "
.
$this
->
config
[
'API_Keys'
][
'Tmdb_Key'
]
.
"<>"
.
$tmdbKey
.
"
\n\n\n
"
;
$tmdb
=
$this
->
jsonCacheDecoder
(
"https://api.themoviedb.org/3/find/tt"
.
$Film
[
"imdbID"
]
.
"?external_source=imdb_id&api_key="
.
$tmdbKey
.
"&language=de"
);
if
(
isset
(
$tmdb
[
"movie_results"
])){
if
(
isset
(
$tmdb
[
"movie_results"
][
0
][
"overview"
])){
echo
" done!"
.
PHP_EOL
;
$DataArray
[
"summary"
]
=
$tmdb
[
"movie_results"
][
0
][
"overview"
];
}
else
{
echo
" fail2!"
.
PHP_EOL
;
$fehler
.=
$this
->
Console
->
error
(
"keine summary gefunden für imdbID "
.
$Film
[
"imdbID"
]
.
"!"
)
.
PHP_EOL
;
}
$tmdbURL
=
"https://api.themoviedb.org/3/movie/"
.
$tmdb
[
"movie_results"
][
0
][
"id"
]
.
"?api_key="
.
$tmdbKey
.
"&language=de&append_to_response=trailers"
;
$tmdbData1
=
$this
->
jsonCacheDecoder
(
$tmdbURL
);
if
(
isset
(
$tmdbData1
[
"trailers"
][
"youtube"
][
0
][
"source"
])){
//TODO youtube Key auf 11 Zeichen prüfen!!
$youtubeDE
=
str_replace
(
"&hd=1"
,
""
,
$tmdbData1
[
"trailers"
][
"youtube"
][
0
][
"source"
]);
if
(
strpos
(
$youtubeDE
,
"youtube"
)
>
0
){
echo
"doofer IFrame....!!!"
;
}
else
{
$DataArray
[
"youtube"
]
=
"DE:"
.
$youtubeDE
;
}
}
else
{
$tmdbURL2
=
"https://api.themoviedb.org/3/movie/"
.
$tmdb
[
"movie_results"
][
0
][
"id"
]
.
"?api_key="
.
$tmdbKey
.
"&language=en&append_to_response=trailers"
;
$tmdbData2
=
$this
->
jsonCacheDecoder
(
$tmdbURL2
);
if
(
isset
(
$tmdbData2
[
"trailers"
][
"youtube"
][
0
][
"source"
])){
$youtubeEN
=
str_replace
(
"&hd=1"
,
""
,
$tmdbData1
[
"trailers"
][
"youtube"
][
0
][
"source"
]);
if
(
strpos
(
$youtubeEN
,
"youtube"
)
>
0
){
echo
"doofer IFrame....!!!"
;
}
else
{
$DataArray
[
"youtube"
]
=
"EN:"
.
$youtubeEN
;
}
}
else
{
$fehler
.=
$this
->
Console
->
error
(
"kein Trailer gefunden für imdbID "
.
$Film
[
"imdbID"
]
.
"!"
)
.
PHP_EOL
;
}
}
}
else
{
echo
" fail1!"
.
PHP_EOL
;
}
}
/**
* @param imdb
* @param fehler
...
...
@@ -411,7 +421,8 @@ class Media {
$array
[
"Genre"
]
=
$imdb
->
getGenre
();
$array
[
"Schauspieler"
]
=
$imdb
->
getCastAsOwn
(
0
,
false
);
$array
[
"fsk"
]
=
$this
->
gibFSK
(
$imdb
);
// TODO Summery und fsk und Youtube hinzufügen
$this
->
gibTMDBdata
(
$array
[
"imdbID"
],
$array
);
// TODO Summery und Youtube hinzufügen
}
else
{
echo
$this
->
Console
->
error
(
"imdbID nicht bei imdb gefunden!"
)
.
PHP_EOL
;
file_put_contents
(
"./phpTestout/"
.
$array
[
"imdbID"
]
.
".txt"
,
"Keine Infos auf imdbID gefunden: "
.
$Pfad
.
$FilenameOrg
.
PHP_EOL
,
FILE_APPEND
);
...
...
@@ -649,6 +660,19 @@ class Media {
}
return
$this
->
FolderArray
;
}
private
function
jsonCacheDecoder
(
$url
){
$CacheFolderName
=
"JsonCache/"
;
exec
(
"rm "
.
$CacheFolderName
.
date
(
"y-W_"
,
time
()
-
14
*
24
*
3600
)
.
"*"
);
exec
(
"rm "
.
$CacheFolderName
.
date
(
"y-W_"
,
time
()
-
7
*
24
*
3600
)
.
"*"
);
if
(
!
is_dir
(
$CacheFolderName
)){
exec
(
"mkdir "
.
$CacheFolderName
);
}
$filename
=
date
(
"y-W_"
,
time
())
.
md5
(
$url
)
.
".json"
;
//TODO Cachetime Ändern
if
(
!
file_exists
(
$CacheFolderName
.
$filename
)){
file_put_contents
(
$CacheFolderName
.
$filename
,
file_get_contents
(
$url
));
}
return
json_decode
(
file_get_contents
(
$CacheFolderName
.
$filename
),
true
);
}
/**
* Cover download
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment