NNTmux /
newznab-tmux
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Models; |
||
| 4 | |||
| 5 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
||
| 6 | use Illuminate\Database\Eloquent\Model; |
||
| 7 | use Mhor\MediaInfo\Container\MediaInfoContainer; |
||
| 8 | |||
| 9 | class MediaInfo extends Model |
||
| 10 | { |
||
| 11 | use HasFactory; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 12 | |||
| 13 | protected $guarded = []; |
||
| 14 | |||
| 15 | public static function addData($id, MediaInfoContainer $xmlArray): void |
||
| 16 | { |
||
| 17 | $mediainfoArray = $xmlArray->getGeneral(); |
||
| 18 | if (! $mediainfoArray) { |
||
| 19 | return; |
||
| 20 | } |
||
| 21 | |||
| 22 | // Check if we have the same release in the database |
||
| 23 | if (self::where('releases_id', $id)->exists()) { |
||
| 24 | return; |
||
| 25 | } |
||
| 26 | |||
| 27 | $mediaUniqueId = $mediainfoArray->get('unique_id'); |
||
| 28 | // If unique_id is not present or is 0 or 0x0, we don't want to store it, as it's not unique |
||
| 29 | if ($mediaUniqueId === null || $mediaUniqueId === '0' || $mediaUniqueId === '0x0' || $mediaUniqueId === 0) { |
||
| 30 | $mediaUniqueId = null; |
||
|
0 ignored issues
–
show
|
|||
| 31 | } |
||
| 32 | |||
| 33 | self::insertOrIgnore([ |
||
| 34 | 'releases_id' => $id, |
||
| 35 | 'movie_name' => $mediainfoArray->get('movie_name') ?? null, |
||
| 36 | 'file_name' => $mediainfoArray->get('file_name') ?? null, |
||
| 37 | 'unique_id' => $mediainfoArray->get('unique_id') ?? null, |
||
| 38 | 'created_at' => now(), |
||
| 39 | 'updated_at' => now(), |
||
| 40 | ]); |
||
| 41 | } |
||
| 42 | } |
||
| 43 |