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
19fcdd05
You need to sign in or sign up before continuing.
Commit
19fcdd05
authored
Jan 26, 2016
by
Nico Schallehn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
33736a07
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
156 additions
and
0 deletions
+156
-0
media.php
media.php
+1
-0
mediainfo.class.php
mediainfo.class.php
+155
-0
No files found.
media.php
View file @
19fcdd05
...
...
@@ -2,6 +2,7 @@
include
'./color.class.php'
;
include
'./media.class.php'
;
include
'./imdb.class.php'
;
include
'./mediainfo.class.php'
;
$Console
=
new
Console
();
$Console
->
clearscreen
();
...
...
mediainfo.class.php
0 → 100644
View file @
19fcdd05
<?php
/*
* purpose of this class is to retrieve media info from movie/video files
* NO media file is provided; so you have to use of your own.
* "mediainfo" dependancy (MEDIAINFO must be installed ...http://mediainfo.sourceforge.net - for ubuntu: sudo apt-get install mediainfo)
* Tested on debian/ubuntu
*
*/
class
mediaInfo
{
var
$filename
;
var
$media_data
;
var
$arrGeneral
;
var
$arrVideo
;
var
$arrAudio
;
/*
* Initialize the class
* Get the media info of the passed file
*/
function
__construct
(
$filename
=
''
){
$mediainfo
=
trim
(
shell_exec
(
'type -P mediainfo'
));
if
(
empty
(
$mediainfo
)){
die
(
'<h1>Mediainfo is not available</h1>'
);
}
if
(
$filename
!=
''
){
$this
->
filename
=
trim
(
$filename
);
if
(
!
file_exists
(
$this
->
filename
))
die
(
'File does not exists.'
);
$this
->
filename
=
escapeshellarg
(
$this
->
filename
);
$this
->
media_data
=
shell_exec
(
"mediainfo
$this->filename
"
);
}
$this
->
make_info_array
();
}
/*
* Print a PREformatted info of the media file
*/
function
print_media_info
(){
echo
(
'<pre>'
.
$this
->
media_data
.
'</pre>'
);
}
/*
* Makes 3 arrays with general, video and audio info
*/
function
make_info_array
(){
$arrData
=
explode
(
chr
(
10
),
$this
->
media_data
);
$general
=
TRUE
;
$audio
=
FALSE
;
$video
=
FALSE
;
$count
=
0
;
if
(
is_array
(
$arrData
)){
foreach
(
$arrData
as
$key
=>
$val
){
$arrProperty
=
explode
(
': '
,
$val
);
if
(
array_key_exists
(
1
,
$arrProperty
)
&&
TRUE
===
$general
&&
$count
==
0
)
$this
->
arrGeneral
[
trim
(
$arrProperty
[
0
])]
=
trim
(
$arrProperty
[
1
]);
if
(
array_key_exists
(
1
,
$arrProperty
)
&&
TRUE
===
$video
&&
$count
==
1
)
$this
->
arrVideo
[
trim
(
$arrProperty
[
0
])]
=
trim
(
$arrProperty
[
1
]);
if
(
array_key_exists
(
1
,
$arrProperty
)
&&
TRUE
===
$audio
&&
$count
==
2
)
$this
->
arrAudio
[
trim
(
$arrProperty
[
0
])]
=
trim
(
$arrProperty
[
1
]);
if
(
trim
(
$arrProperty
[
0
])
==
'Video'
&&
!
array_key_exists
(
1
,
$arrProperty
)){
$general
=
FALSE
;
$video
=
TRUE
;
$count
++
;}
if
(
trim
(
$arrProperty
[
0
])
==
'Audio'
&&
!
array_key_exists
(
1
,
$arrProperty
)){
$video
=
FALSE
;
$audio
=
TRUE
;
$count
++
;}
}
}
}
/*
* Returns an array with the general info
*/
function
get_general_info
(){
return
(
$this
->
arrGeneral
);
}
/*
* Returns an array with the video info
*/
function
get_video_info
(){
return
(
$this
->
arrVideo
);
}
/*
* Returns an array with the audio info
*/
function
get_audio_info
(){
return
(
$this
->
arrAudio
);
}
/*
* Returns an item from the array with the general info
*/
function
get_general_property
(
$property
){
if
(
array_key_exists
(
$property
,
$this
->
arrGeneral
)){
return
(
$this
->
arrGeneral
[
$property
]);
}
else
{
return
(
'Property does not exists'
);
}
}
/*
* Returns an item from the array with the video info
*/
function
get_video_property
(
$property
){
if
(
array_key_exists
(
$property
,
$this
->
arrVideo
)){
return
(
$this
->
arrVideo
[
$property
]);
}
else
{
return
(
'Property does not exists'
);
}
}
/*
* Returns an item from the array with the audio info
*/
function
get_audio_property
(
$property
){
if
(
array_key_exists
(
$property
,
$this
->
arrAudio
)){
return
(
$this
->
arrAudio
[
$property
]);
}
else
{
return
(
'Property does not exists'
);
}
}
/*
* Returns the aspect ratio of a media file
*/
function
get_aspect_ratio
(){
return
(
$this
->
arrVideo
[
'Display aspect ratio'
]);
}
/*
* Returns the width of a media file
*/
function
get_width
(){
return
((
int
)
str_replace
(
' '
,
''
,
$this
->
arrVideo
[
'Width'
]));
}
/*
* Returns the height of a media file
*/
function
get_height
(){
return
((
int
)
str_replace
(
' '
,
''
,
$this
->
arrVideo
[
'Height'
]));
}
/*
* Returns the filesize of a media file
*/
function
get_file_size
(){
return
(
$this
->
arrGeneral
[
'File size'
]);
}
}
?>
\ No newline at end of file
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