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
8c4669b7
Commit
8c4669b7
authored
Mar 14, 2016
by
Nico Schallehn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test mit serien und mediainfo
parent
df28eafc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
54 deletions
+71
-54
media.class.php
media.class.php
+71
-54
No files found.
media.class.php
View file @
8c4669b7
...
@@ -343,6 +343,64 @@ class Media {
...
@@ -343,6 +343,64 @@ class Media {
echo
"Not Found!"
.
PHP_EOL
;
echo
"Not Found!"
.
PHP_EOL
;
}
}
}
}
private
function
gibMediaInfo
(
$Datei
,
&
$DataArray
){
$array
[
"size"
]
=
$this
->
getfileSize
(
$Datei
);
if
(
!
file_exists
(
'/tmp/'
.
$array
[
"imdbID"
]
.
(
!
$array
[
"3d"
]
==
""
?
"3d"
:
""
)
.
'.xml'
)){
$befehl
=
'mediainfo --Output=XML "'
.
$Datei
.
'" > /tmp/'
.
$array
[
"imdbID"
]
.
(
!
$array
[
"3d"
]
==
""
?
"3d"
:
""
)
.
(
isset
(
$array
[
"Season"
])
?
"S"
.
$array
[
"Season"
]
.
"E"
.
$array
[
"Episode"
]
:
""
)
.
'.xml'
;
exec
(
$befehl
);
}
$xmlstring
=
file_get_contents
(
'/tmp/'
.
$array
[
"imdbID"
]
.
(
!
$array
[
"3d"
]
==
""
?
"3d"
:
""
)
.
(
isset
(
$array
[
"Season"
])
?
"S"
.
$array
[
"Season"
]
.
"E"
.
$array
[
"Episode"
]
:
""
)
.
'.xml'
);
//TODO Testen ob 3d Geht....
$xml
=
simplexml_load_string
(
$xmlstring
);
$json
=
json_encode
(
$xml
,
JSON_PRETTY_PRINT
);
$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"
])));
//TODO Resolution aus diesen werten neusetzen
$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
(
$array
[
"channelsger"
])){
$array
[
"channelsger"
]
=
substr
(
$array
[
"channelsger"
],
strripos
(
$array
[
"channelsger"
],
"/"
)
+
1
);
if
(
!
is_numeric
(
$array
[
"channelsger"
])){
echo
$this
->
Console
->
error
(
"channelsger ist nicht Numerisch!"
)
.
PHP_EOL
;
file_put_contents
(
"./phpTestout/imdbID/"
.
$array
[
"imdbID"
]
.
".txt"
,
"channelsger ist nicht Numerisch!"
.
PHP_EOL
,
FILE_APPEND
);
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
(
$array
[
"channelseng"
])){
$array
[
"channelseng"
]
=
substr
(
$array
[
"channelseng"
],
strripos
(
$array
[
"channelseng"
],
"/"
)
+
1
);
if
(
!
is_numeric
(
$array
[
"channelseng"
])){
echo
$this
->
Console
->
error
(
"channelseng ist nicht Numerisch!"
)
.
PHP_EOL
;
file_put_contents
(
"./phpTestout/imdbID/"
.
$array
[
"imdbID"
]
.
".txt"
,
"channelseng ist nicht Numerisch!"
.
PHP_EOL
,
FILE_APPEND
);
return
false
;
}
}
}
}
break
;
}
}
}
/**
/**
* @param imdbID
* @param imdbID
* @param DataArray
* @param DataArray
...
@@ -477,6 +535,17 @@ class Media {
...
@@ -477,6 +535,17 @@ class Media {
}
}
echo
"imdbID: "
.
$array
[
"imdbID"
]
.
">"
.
$array
[
"Season"
]
.
">"
.
$array
[
"Episode"
]
.
PHP_EOL
;
echo
"imdbID: "
.
$array
[
"imdbID"
]
.
">"
.
$array
[
"Season"
]
.
">"
.
$array
[
"Episode"
]
.
PHP_EOL
;
if
(
!
(
$minimal
==
"nfo"
)){
if
((
$minimal
==
"check"
)
OR
(
$minimal
==
"einlesen"
)){
}
if
((
$minimal
==
"checkfile"
)
OR
(
$minimal
==
"einlesen"
)){
echo
" Hole Daten von mediainfo... "
;
$array
=
gibMediaInfo
(
$Pfad
.
$Filename
,
$array
);
echo
" done!"
.
PHP_EOL
;
}
}
return
$array
;
return
$array
;
}
}
...
@@ -578,60 +647,8 @@ class Media {
...
@@ -578,60 +647,8 @@ class Media {
if
((
$minimal
==
"checkfile"
)
OR
(
$minimal
==
"einlesen"
)){
if
((
$minimal
==
"checkfile"
)
OR
(
$minimal
==
"einlesen"
)){
// werte von MediaInfo holen...
// werte von MediaInfo holen...
echo
" Hole Daten von mediainfo... "
;
echo
" Hole Daten von mediainfo... "
;
$array
[
"size"
]
=
$this
->
getfileSize
(
$Pfad
.
$FilenameOrg
);
$array
=
gibMediaInfo
(
$Pfad
.
$FilenameOrg
,
$array
);
if
(
!
file_exists
(
'/tmp/'
.
$array
[
"imdbID"
]
.
(
!
$array
[
"3d"
]
==
""
?
"3d"
:
""
)
.
'.xml'
)){
$befehl
=
'mediainfo --Output=XML "'
.
$Pfad
.
$FilenameOrg
.
'" > /tmp/'
.
$array
[
"imdbID"
]
.
(
!
$array
[
"3d"
]
==
""
?
"3d"
:
""
)
.
'.xml'
;
exec
(
$befehl
);
}
$xmlstring
=
file_get_contents
(
'/tmp/'
.
$array
[
"imdbID"
]
.
(
!
$array
[
"3d"
]
==
""
?
"3d"
:
""
)
.
'.xml'
);
//TODO Testen ob 3d Geht....
$xml
=
simplexml_load_string
(
$xmlstring
);
$json
=
json_encode
(
$xml
,
JSON_PRETTY_PRINT
);
$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"
])));
//TODO Resolution aus diesen werten neusetzen
$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
(
$array
[
"channelsger"
])){
$array
[
"channelsger"
]
=
substr
(
$array
[
"channelsger"
],
strripos
(
$array
[
"channelsger"
],
"/"
)
+
1
);
if
(
!
is_numeric
(
$array
[
"channelsger"
])){
echo
$this
->
Console
->
error
(
"channelsger ist nicht Numerisch!"
)
.
PHP_EOL
;
file_put_contents
(
"./phpTestout/imdbID/"
.
$array
[
"imdbID"
]
.
".txt"
,
"channelsger ist nicht Numerisch!"
.
PHP_EOL
,
FILE_APPEND
);
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
(
$array
[
"channelseng"
])){
$array
[
"channelseng"
]
=
substr
(
$array
[
"channelseng"
],
strripos
(
$array
[
"channelseng"
],
"/"
)
+
1
);
if
(
!
is_numeric
(
$array
[
"channelseng"
])){
echo
$this
->
Console
->
error
(
"channelseng ist nicht Numerisch!"
)
.
PHP_EOL
;
file_put_contents
(
"./phpTestout/imdbID/"
.
$array
[
"imdbID"
]
.
".txt"
,
"channelseng ist nicht Numerisch!"
.
PHP_EOL
,
FILE_APPEND
);
return
false
;
}
}
}
}
break
;
}
}
echo
" done!"
.
PHP_EOL
;
echo
" done!"
.
PHP_EOL
;
}
}
}
}
...
...
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