Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC-Android
Manage
Activity
Members
Labels
Plan
Issues
531
Issue boards
Milestones
Wiki
Code
Merge requests
14
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC-Android
Commits
677e4eab
Commit
677e4eab
authored
5 years ago
by
Geoffrey Métais
Committed by
Geoffrey Métais
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Use app context for media fetching
parent
60ed93bf
No related branches found
No related tags found
1 merge request
!288
Moviepedia API implementation
Pipeline
#11390
passed with stage
in 25 minutes and 40 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
vlc-android/src/org/videolan/vlc/MediaParsingService.kt
+1
-1
1 addition, 1 deletion
vlc-android/src/org/videolan/vlc/MediaParsingService.kt
vlc-android/src/org/videolan/vlc/moviepedia/MoviepediaIndexer.kt
+33
-32
33 additions, 32 deletions
...roid/src/org/videolan/vlc/moviepedia/MoviepediaIndexer.kt
with
34 additions
and
33 deletions
vlc-android/src/org/videolan/vlc/MediaParsingService.kt
+
1
−
1
View file @
677e4eab
...
...
@@ -382,7 +382,7 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb, LifecycleOwn
lastNotificationTime
=
0L
//todo reenable entry point when ready
if
(
BuildConfig
.
DEBUG
)
try
{
MoviepediaIndexer
.
indexMedialib
(
this
@MediaParsingService
)
MoviepediaIndexer
.
indexMedialib
(
applicationContext
)
}
catch
(
e
:
Exception
)
{
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
this
::
class
.
java
.
simpleName
,
"${e.cause}"
)
}
...
...
This diff is collapsed.
Click to expand it.
vlc-android/src/org/videolan/vlc/moviepedia/MoviepediaIndexer.kt
+
33
−
32
View file @
677e4eab
...
...
@@ -27,7 +27,10 @@ package org.videolan.vlc.moviepedia
import
android.content.Context
import
android.net.Uri
import
android.util.Log
import
kotlinx.coroutines.*
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.MainScope
import
kotlinx.coroutines.launch
import
org.videolan.medialibrary.interfaces.AbstractMedialibrary
import
org.videolan.medialibrary.interfaces.media.AbstractMediaWrapper
import
org.videolan.vlc.BuildConfig
...
...
@@ -44,40 +47,38 @@ import org.videolan.vlc.util.getLocaleLanguages
object
MoviepediaIndexer
:
CoroutineScope
by
MainScope
()
{
fun
indexMedialib
(
context
:
Context
)
{
launch
{
withContext
(
Dispatchers
.
IO
)
{
val
medias
=
context
.
getFromMl
{
getPagedVideos
(
AbstractMedialibrary
.
SORT_DEFAULT
,
false
,
1000
,
0
)
}
val
filesToIndex
=
HashMap
<
Long
,
Uri
>()
medias
.
forEach
{
if
(
it
.
getMetaLong
(
AbstractMediaWrapper
.
META_METADATA_RETRIEVED
)
!=
1L
)
filesToIndex
[
it
.
id
]
=
it
.
uri
}
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
this
::
class
.
java
.
simpleName
,
"Retrieving infos for ${filesToIndex.size} files"
)
for
(
filesToIndex
in
filesToIndex
)
{
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
this
::
class
.
java
.
simpleName
,
"Retrieving infos for: ${filesToIndex.value.lastPathSegment}"
)
}
val
repo
=
MoviepediaApiRepository
.
getInstance
()
val
results
=
try
{
repo
.
searchMediaBatch
(
filesToIndex
)
}
catch
(
e
:
Exception
)
{
return
@withContext
}
medias
.
forEach
{
media
->
media
?.
setLongMeta
(
AbstractMediaWrapper
.
META_METADATA_RETRIEVED
,
1L
)
}
results
.
forEach
{
result
->
result
.
lucky
?.
let
{
val
media
=
medias
.
find
{
it
.
id
==
result
.
id
.
toLong
()
}
try
{
saveMediaMetadata
(
context
,
media
,
it
,
retrieveCast
=
false
,
removePersonOrphans
=
false
)
}
catch
(
e
:
Exception
)
{
media
?.
setLongMeta
(
251
,
0L
)
}
launch
(
Dispatchers
.
IO
)
{
val
medias
=
context
.
getFromMl
{
getPagedVideos
(
AbstractMedialibrary
.
SORT_DEFAULT
,
false
,
1000
,
0
)
}
val
filesToIndex
=
HashMap
<
Long
,
Uri
>()
medias
.
forEach
{
if
(
it
.
getMetaLong
(
AbstractMediaWrapper
.
META_METADATA_RETRIEVED
)
!=
1L
)
filesToIndex
[
it
.
id
]
=
it
.
uri
}
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
this
::
class
.
java
.
simpleName
,
"Retrieving infos for ${filesToIndex.size} files"
)
for
(
filesToIndex
in
filesToIndex
)
{
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
this
::
class
.
java
.
simpleName
,
"Retrieving infos for: ${filesToIndex.value.lastPathSegment}"
)
}
val
repo
=
MoviepediaApiRepository
.
getInstance
()
val
results
=
try
{
repo
.
searchMediaBatch
(
filesToIndex
)
}
catch
(
e
:
Exception
)
{
return
@launch
}
medias
.
forEach
{
media
->
media
?.
setLongMeta
(
AbstractMediaWrapper
.
META_METADATA_RETRIEVED
,
1L
)
}
results
.
forEach
{
result
->
result
.
lucky
?.
let
{
val
media
=
medias
.
find
{
it
.
id
==
result
.
id
.
toLong
()
}
try
{
saveMediaMetadata
(
context
,
media
,
it
,
retrieveCast
=
false
,
removePersonOrphans
=
false
)
}
catch
(
e
:
Exception
)
{
media
?.
setLongMeta
(
251
,
0L
)
}
}
removePersonOrphans
(
context
)
}
removePersonOrphans
(
context
)
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment