Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hdvinnie/mediainfo-helper

Laravel Helper For Parsing MediaInfo Dumps
https://github.com/hdvinnie/mediainfo-helper

helper laravel mediainfo metadata package

Last synced: about 1 month ago
JSON representation

Laravel Helper For Parsing MediaInfo Dumps

Awesome Lists containing this project

README

        

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/2cf2367f96904e08b47507cf8331cfa2)](https://www.codacy.com/app/HDVinnie/MediaInfo-Helper?utm_source=github.com&utm_medium=referral&utm_content=HDVinnie/MediaInfo-Helper&utm_campaign=badger)
[![Latest Stable Version](https://poser.pugx.org/hdvinnie/mediainfo-helper/v/stable)](https://packagist.org/packages/hdvinnie/mediainfo-helper) [![Total Downloads](https://poser.pugx.org/hdvinnie/mediainfo-helper/downloads)](https://packagist.org/packages/hdvinnie/mediainfo-helper)

# MediaInfo-Helper

A Laravel helper for parsing MediaInfo dumps.

## Install

Via Composer

``` bash
$ composer require hdvinnie/mediainfo-helper
```

## Usage

**Parsing a MediaInfo string**

Returns an array containing the parsed information.

```php
$parser = new MediaInfo();
$parsed = $parser->parse($mediaInfo);
```

## Example

**In Your Controller**
```php
$general = null;
$video = null;
$settings = null;
$audio = null;
$general_crumbs = null;
$text_crumbs = null;
$subtitle = null;
$view_crumbs = null;
$video_crumbs = null;
$settings = null;
$audio_crumbs = null;
$subtitle = null;
$subtitle_crumbs = null;
if ($movie->mediainfo != null) {
$parser = new MediaInfo();
$parsed = $parser->parse($movie->mediainfo);
$view_crumbs = $parser->prepareViewCrumbs($parsed);
$general = $parsed['general'];
$general_crumbs = $view_crumbs['general'];
$video = $parsed['video'];
$video_crumbs = $view_crumbs['video'];
$settings = ($parsed['video'] !== null && isset($parsed['video'][0]) && isset($parsed['video'][0]['encoding_settings'])) ? $parsed['video'][0]['encoding_settings'] : null;
$audio = $parsed['audio'];
$audio_crumbs = $view_crumbs['audio'];
$subtitle = $parsed['text'];
$text_crumbs = $view_crumbs['text'];
}
```

**In You View**
```html
@section('content')
@if($movie->mediainfo != null)




Media Info Output


@if($general !== null && isset($general['file_name']))
FILE:
{{ $general['file_name'] }}




@endif
@if($general_crumbs !== null)
GENERAL:

@foreach($general_crumbs as $crumb)
{{ $crumb }}
@if(!$loop->last)
/
@endif
@endforeach





@endif
@if($video_crumbs !== null)
@foreach($video_crumbs as $key => $v)
VIDEO:

@foreach($v as $crumb)
{{ $crumb }}
@if(!$loop->last)
/
@endif
@endforeach





@endforeach
@endif
@if($audio_crumbs !== null)
@foreach($audio_crumbs as $key => $a)
AUDIO {{ ++$key }}:

@foreach($a as $crumb)
{{ $crumb }}
@if(!$loop->last)
/
@endif
@endforeach



@endforeach
@endif


@if($text_crumbs !== null)
@foreach($text_crumbs as $key => $s)
SUBTITLE {{ ++$key }}:

@foreach($s as $crumb)
{{ $crumb }}
@if(!$loop->last)
/
@endif
@endforeach



@endforeach
@endif
@if($settings)


ENCODE SETTINGS:


{{ $settings }}

@endif






Show/Hide Original Dump


{{ $movie->mediainfo }}








@endif
@endsection

@section('javascripts')

$(document).ready(function(){

$(".slidingDiv").hide();
$(".show_hide").show();

$('.show_hide').click(function(){
$(".slidingDiv").slideToggle();
});

});

@endsection
```

## Testing

``` bash
$ composer test
```

## License
[The MIT License](LICENSE)