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
7654dfc9
Commit
7654dfc9
authored
Jan 26, 2016
by
Nico Schallehn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
a2da782a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
95 deletions
+97
-95
media.class.php
media.class.php
+97
-95
No files found.
media.class.php
View file @
7654dfc9
...
...
@@ -116,106 +116,108 @@ class Media {
//return ;
}
private
function
parseMovie
(
$Pfad
,
$Filename
){
$array
=
array
();
$FilenameOrg
=
$Filename
;
$array
[
"hdd"
]
=
$this
->
HDDID
;
if
(
strpos
(
$Filename
,
"(3D)"
)
>
0
){
$Filename
=
str_replace
(
"(3D)"
,
""
,
$Filename
);
$array
[
"3d"
]
=
"ja"
;
}
else
{
$array
[
"3d"
]
=
""
;
}
if
(
strpos
(
$Filename
,
"(720p)"
)
>
0
){
$Filename
=
str_replace
(
"(720p)"
,
""
,
$Filename
);
$array
[
"resolution"
]
=
"720p"
;
}
else
if
(
strpos
(
$Filename
,
"(1080p)"
)
>
0
){
$Filename
=
str_replace
(
"(1080p)"
,
""
,
$Filename
);
$array
[
"resolution"
]
=
"1080p"
;
}
else
if
(
strpos
(
$Filename
,
"(SD)"
)
>
0
){
$Filename
=
str_replace
(
"(SD)"
,
""
,
$Filename
);
$array
[
"resolution"
]
=
"SD"
;
}
$array
[
"imdbID"
]
=
substr
(
$Filename
,
strripos
(
$Filename
,
"("
)
+
1
,
7
);
$array
[
"name"
]
=
trim
(
substr
(
$Filename
,
0
,
strripos
(
$Filename
,
"("
)));
/**/
$array
[
"Endung"
]
=
trim
(
substr
(
$Filename
,
strripos
(
$Filename
,
"."
)
+
1
));
echo
$Pfad
.
$FilenameOrg
.
PHP_EOL
;
// Werte aus IMdb Auslesen...
$imdb
=
new
IMDB
(
"http://www.imdb.com/title/tt"
.
$array
[
"imdbID"
]
.
"/"
);
if
(
$imdb
->
isReady
)
{
//var_dump($imdb->getAll());
$array
[
"year"
]
=
$imdb
->
getYear
();
$array
[
"size"
]
=
$this
->
getfileSize
(
$Pfad
.
$FilenameOrg
);
//$array["md5"] = md5_file($Pfad.$FilenameOrg); //TODO Einkommentieren für md5
$array
[
"rating"
]
=
$imdb
->
getRating
();
}
else
{
echo
"nichts gefunden!"
.
PHP_EOL
;
}
// werte von MediaInfo holen...
/*$mediainfo = new mediaInfo($Pfad.$FilenameOrg);
$array["width"] = $mediainfo->get_width();
$array["height"] = $mediainfo->get_height();
$array["Duration"] = $mediainfo->get_video_property("Duration");
$array["Duration"] = $mediainfo->get_video_property("Duration");
*/
$p
=
xml_parser_create
();
$befehl
=
'mediainfo --Output=XML "'
.
$Pfad
.
$FilenameOrg
.
'" > /tmp/'
.
$array
[
"imdbID"
]
.
'.xml'
;
exec
(
$befehl
);
//echo $befehl;
$xmlstring
=
file_get_contents
(
'/tmp/'
.
$array
[
"imdbID"
]
.
'.xml'
);
/*echo $xml;
xml_parse_into_struct($p, $xml, $vals, $index);
xml_parser_free($p);*/
$xml
=
simplexml_load_string
(
$xmlstring
);
$json
=
json_encode
(
$xml
,
JSON_PRETTY_PRINT
);
//echo $json;
$array2
=
json_decode
(
$json
,
TRUE
);
foreach
(
$array2
[
"File"
][
"track"
]
as
$key
=>
$value
)
{
//echo " ".$key." ".$value["@attributes"]["type"].PHP_EOL;
switch
(
$value
[
"@attributes"
][
"type"
])
{
case
"General"
:
$array
[
"vcodec"
]
=
str_replace
(
"Matroska"
,
"mkv"
,
$value
[
"Format"
]);
$array
[
"duration"
]
=
$this
->
getRunTime
(
$value
[
"Duration"
]);
$array
[
"totalbitrate"
]
=
round
(
trim
(
str_replace
(
" "
,
""
,
str_replace
(
"Mbps"
,
""
,
$value
[
"Overall_bit_rate"
])))
*
1024
,
0
);
break
;
case
"Video"
:
$array
[
"width"
]
=
trim
(
str_replace
(
" "
,
""
,
str_replace
(
"pixels"
,
""
,
$value
[
"Width"
])));
$array
[
"height"
]
=
trim
(
str_replace
(
" "
,
""
,
str_replace
(
"pixels"
,
""
,
$value
[
"Height"
])));
break
;
case
"Audio"
:
if
(
isset
(
$value
[
"Language"
])){
if
((
$value
[
"Language"
]
==
"Deutsch"
)
OR
(
$value
[
"Language"
]
==
"German"
)){
$array
[
"acodecger"
]
=
$value
[
"Format"
];
$array
[
"abitrateger"
]
=
round
(
trim
(
str_replace
(
" "
,
""
,
str_replace
(
"Kbps"
,
""
,
$value
[
"Bit_rate"
]))),
0
);
$array
[
"channelsger"
]
=
str_replace
(
" channels"
,
""
,
$value
[
"Channel_s_"
]);
if
(
!
is_numeric
(
str_replace
(
" channels"
,
""
,
$value
[
"Channel_s_"
]))){
return
false
;
if
(
is_file
(
$Pfad
.
$Filename
)){
$array
=
array
();
$FilenameOrg
=
$Filename
;
$array
[
"hdd"
]
=
$this
->
HDDID
;
if
(
strpos
(
$Filename
,
"(3D)"
)
>
0
){
$Filename
=
str_replace
(
"(3D)"
,
""
,
$Filename
);
$array
[
"3d"
]
=
"ja"
;
}
else
{
$array
[
"3d"
]
=
""
;
}
if
(
strpos
(
$Filename
,
"(720p)"
)
>
0
){
$Filename
=
str_replace
(
"(720p)"
,
""
,
$Filename
);
$array
[
"resolution"
]
=
"720p"
;
}
else
if
(
strpos
(
$Filename
,
"(1080p)"
)
>
0
){
$Filename
=
str_replace
(
"(1080p)"
,
""
,
$Filename
);
$array
[
"resolution"
]
=
"1080p"
;
}
else
if
(
strpos
(
$Filename
,
"(SD)"
)
>
0
){
$Filename
=
str_replace
(
"(SD)"
,
""
,
$Filename
);
$array
[
"resolution"
]
=
"SD"
;
}
$array
[
"imdbID"
]
=
substr
(
$Filename
,
strripos
(
$Filename
,
"("
)
+
1
,
7
);
$array
[
"name"
]
=
trim
(
substr
(
$Filename
,
0
,
strripos
(
$Filename
,
"("
)));
/**/
$array
[
"Endung"
]
=
trim
(
substr
(
$Filename
,
strripos
(
$Filename
,
"."
)
+
1
));
echo
$Pfad
.
$FilenameOrg
.
PHP_EOL
;
// Werte aus IMdb Auslesen...
$imdb
=
new
IMDB
(
"http://www.imdb.com/title/tt"
.
$array
[
"imdbID"
]
.
"/"
);
if
(
$imdb
->
isReady
)
{
//var_dump($imdb->getAll());
$array
[
"year"
]
=
$imdb
->
getYear
();
$array
[
"size"
]
=
$this
->
getfileSize
(
$Pfad
.
$FilenameOrg
);
//$array["md5"] = md5_file($Pfad.$FilenameOrg); //TODO Einkommentieren für md5
$array
[
"rating"
]
=
$imdb
->
getRating
();
}
else
{
echo
"nichts gefunden!"
.
PHP_EOL
;
}
// werte von MediaInfo holen...
/*$mediainfo = new mediaInfo($Pfad.$FilenameOrg);
$array["width"] = $mediainfo->get_width();
$array["height"] = $mediainfo->get_height();
$array["Duration"] = $mediainfo->get_video_property("Duration");
$array["Duration"] = $mediainfo->get_video_property("Duration");
*/
$p
=
xml_parser_create
();
$befehl
=
'mediainfo --Output=XML "'
.
$Pfad
.
$FilenameOrg
.
'" > /tmp/'
.
$array
[
"imdbID"
]
.
'.xml'
;
exec
(
$befehl
);
//echo $befehl;
$xmlstring
=
file_get_contents
(
'/tmp/'
.
$array
[
"imdbID"
]
.
'.xml'
);
/*echo $xml;
xml_parse_into_struct($p, $xml, $vals, $index);
xml_parser_free($p);*/
$xml
=
simplexml_load_string
(
$xmlstring
);
$json
=
json_encode
(
$xml
,
JSON_PRETTY_PRINT
);
//echo $json;
$array2
=
json_decode
(
$json
,
TRUE
);
foreach
(
$array2
[
"File"
][
"track"
]
as
$key
=>
$value
)
{
//echo " ".$key." ".$value["@attributes"]["type"].PHP_EOL;
switch
(
$value
[
"@attributes"
][
"type"
])
{
case
"General"
:
$array
[
"vcodec"
]
=
str_replace
(
"Matroska"
,
"mkv"
,
$value
[
"Format"
]);
$array
[
"duration"
]
=
$this
->
getRunTime
(
$value
[
"Duration"
]);
$array
[
"totalbitrate"
]
=
round
(
trim
(
str_replace
(
" "
,
""
,
str_replace
(
"Mbps"
,
""
,
$value
[
"Overall_bit_rate"
])))
*
1024
,
0
);
break
;
case
"Video"
:
$array
[
"width"
]
=
trim
(
str_replace
(
" "
,
""
,
str_replace
(
"pixels"
,
""
,
$value
[
"Width"
])));
$array
[
"height"
]
=
trim
(
str_replace
(
" "
,
""
,
str_replace
(
"pixels"
,
""
,
$value
[
"Height"
])));
break
;
case
"Audio"
:
if
(
isset
(
$value
[
"Language"
])){
if
((
$value
[
"Language"
]
==
"Deutsch"
)
OR
(
$value
[
"Language"
]
==
"German"
)){
$array
[
"acodecger"
]
=
$value
[
"Format"
];
$array
[
"abitrateger"
]
=
round
(
trim
(
str_replace
(
" "
,
""
,
str_replace
(
"Kbps"
,
""
,
$value
[
"Bit_rate"
]))),
0
);
$array
[
"channelsger"
]
=
str_replace
(
" channels"
,
""
,
$value
[
"Channel_s_"
]);
if
(
!
is_numeric
(
str_replace
(
" channels"
,
""
,
$value
[
"Channel_s_"
]))){
return
false
;
}
}
}
else
if
((
$value
[
"Language"
]
==
"Englisch"
)
OR
(
$value
[
"Language"
]
==
"English"
)){
$array
[
"acodeceng"
]
=
$value
[
"Format"
]
;
$array
[
"abitrateeng"
]
=
round
(
trim
(
str_replace
(
" "
,
""
,
str_replace
(
"Kbps"
,
""
,
$value
[
"Bit_rate"
]))),
0
);
$array
[
"channelseng"
]
=
str_replace
(
" channels"
,
""
,
$value
[
"Channel_s_"
]);
if
(
!
is_numeric
(
str_replace
(
" channels"
,
""
,
$value
[
"Channel_s_"
]))){
return
false
;
else
if
((
$value
[
"Language"
]
==
"Englisch"
)
OR
(
$value
[
"Language"
]
==
"English"
)){
$array
[
"acodeceng"
]
=
$value
[
"Format"
];
$array
[
"abitrateeng"
]
=
round
(
trim
(
str_replace
(
" "
,
""
,
str_replace
(
"Kbps"
,
""
,
$value
[
"Bit_rate"
]))),
0
)
;
$array
[
"channelseng"
]
=
str_replace
(
" channels"
,
""
,
$value
[
"Channel_s_"
]
);
if
(
!
is_numeric
(
str_replace
(
" channels"
,
""
,
$value
[
"Channel_s_"
]))){
return
false
;
}
}
}
}
break
;
default
:
;
break
;
default
:
;
break
;
}
}
foreach
(
$array
as
$key
=>
$value
)
{
echo
" "
.
$key
.
" => '"
.
$value
.
"'"
.
PHP_EOL
;
}
}
foreach
(
$array
as
$key
=>
$value
)
{
echo
" "
.
$key
.
" => '"
.
$value
.
"'"
.
PHP_EOL
;
}
}
private
function
getRunTime
(
$laufzeit
){
...
...
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