mosta17 / embermediamanager

Automatically exported from code.google.com/p/embermediamanager
0 stars 0 forks source link

cached nfo .. #143

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi nul
New idea
Cached nfo, and maybe poster and fanart..
Propose:
Be able to organized your movies even when you dont have acces to your media
ie, on vacantion, or at work with nothing to do but EMM installed on laptop ;)
Implementation:
Save nfo (poster and fanart maybe) to cached directory .. 
Read from there if:
Offline detected.. or by options try to read always first from cache and
write update later)

i have done some investigation.. think is not to hard.. but little
dangerous because can break all EMM ;)

Will sen diff of what i have dome for test proposes

Let it to your consideration!

BTW... tell me to stop if need ;) sometimes I forget to stop ... lol

Index: Ember Media Manager/clsSettings.vb
===================================================================
--- Ember Media Manager/clsSettings.vb  (revision 273)
+++ Ember Media Manager/clsSettings.vb  (working copy)
@@ -120,7 +120,13 @@
     Private _genrefilter As String
     Private _useetasfa As Boolean
     Private _xbmccoms As New List(Of XBMCCom)
+    'Cached Nfo + Poster and fanart... allowing to work offline from the Media
+    ' Will have to consider a write later function.. when cached are save
and not the real ones!
+    Private _usecachenfo As Boolean
+    Private _readfirstcachenfo As Boolean 'Not yet in Use , Means read
caached nfo before trying real nfo ... false do the inverse ofc
+    Private _readcacheimages As Boolean 'Not yet in Use, Means try to load
poster and funart to display from cached ones 

+
     Public Property Version() As String
         Get
             Return Me._version
@@ -979,7 +985,14 @@
             Me._xbmccoms = value
         End Set
     End Property
-
+    Public Property UseCacheNFO() As String
+        Get
+            Return Me._usecachenfo
+        End Get
+        Set(ByVal value As String)
+            Me._usecachenfo = value
+        End Set
+    End Property
     Public Sub New()
         Me.Clear()
     End Sub
@@ -1080,6 +1093,7 @@
         Me._genrefilter = "[All]"
         Me._useetasfa = False
         Me._xbmccoms.Clear()
+        Me._usecachenfo = False
     End Sub

     Public Sub Save()

Index: Ember Media Manager/clsGlobal.vb
===================================================================
--- Ember Media Manager/clsGlobal.vb    (revision 273)
+++ Ember Media Manager/clsGlobal.vb    (working copy)
@@ -708,6 +708,35 @@
         Dim xmlSer As XmlSerializer = Nothing
         Dim xmlMov As New Media.Movie
         Try
+            ' Cached nfo
+            If eSettings.UseCacheNFO Then
+                Dim id As String = vbNullString
+                'Need to get ID from  DB based on Movie/nfo path
+                Using SQLNewcommand As SQLite.SQLiteCommand =
Master.SQLcn.CreateCommand
+                    SQLNewcommand.CommandText = String.Concat("SELECT id
FROM movies WHERE path LIKE """, sPath.Substring(0, sPath.Length -
sPath.LastIndexOf(",")), "%"";")
+                    Dim SQLreader As SQLite.SQLiteDataReader =
SQLNewcommand.ExecuteReader()
+                    If SQLreader.HasRows Then
+                        id = SQLreader("id").ToString
+                    End If
+                End Using
+                If Not id = vbNullString Then
+                    Dim mePath As String =
String.Concat(Application.StartupPath, Path.DirectorySeparatorChar,
"cache", Path.DirectorySeparatorChar, id, ".nfo")
+                    If File.Exists(mePath) AndAlso Not
Master.eSettings.ValidExts.Contains(Path.GetExtension(mePath)) Then
+                        Using xmlSR As StreamReader = New StreamReader(mePath)
+                            xmlSer = New XmlSerializer(GetType(Media.Movie))
+                            xmlMov = CType(xmlSer.Deserialize(xmlSR),
Media.Movie)
+                        End Using
+                        Return xmlMov
+                    End If
+                End If
+            End If
+        Catch
+            ' Don't catch out from Sub on this... still have non cached
nfo to check
+            If Not IsNothing(xmlSer) Then
+                xmlSer = Nothing
+            End If
+        End Try
+        Try
             If File.Exists(sPath) AndAlso Not
Master.eSettings.ValidExts.Contains(Path.GetExtension(sPath)) Then
                 Using xmlSR As StreamReader = New StreamReader(sPath)
                     xmlSer = New XmlSerializer(GetType(Media.Movie))
@@ -1172,7 +1201,6 @@

                 If Not isFile AndAlso eSettings.MovieNFO Then
                     tPath =
Path.Combine(Directory.GetParent(nPath).FullName, "movie.nfo")
-
                     If Not eSettings.OverwriteNfo Then
                         RenameNonConfNfo(tPath)
                     End If
@@ -1181,10 +1209,16 @@
                         Using xmlSW As New StreamWriter(tPath)
                             xmlSer.Serialize(xmlSW, movieToSave)
                         End Using
+                        ' Cached nfo
+                        If eSettings.UseCacheNFO Then
+                            Dim mePath As String =
String.Concat(Application.StartupPath, Path.DirectorySeparatorChar,
"cache", Path.DirectorySeparatorChar, movieToSave.ID, ".nfo")
+                            Using xmlSW As New StreamWriter(mePath)
+                                xmlSer.Serialize(xmlSW, movieToSave)
+                            End Using
+                        End If
                     End If
                 End If
             End If
-
         Catch ex As Exception
             eLog.WriteToErrorLog(ex.Message, ex.StackTrace, "Error")
         End Try

Original issue reported on code.google.com by nfnovais@gmail.com on 9 Jun 2009 at 7:46

GoogleCodeExporter commented 8 years ago
BTW this kinda sovle also the Issue 118 ... lol

Original comment by nfnovais@gmail.com on 9 Jun 2009 at 7:59

GoogleCodeExporter commented 8 years ago
I think this and 118 are completely different requests... 118 would involve 
keeping
the downloaded posters and fanart in the Temp folder until the program is 
closed.
When you try to scrape the images again, it checks for their existence in the 
Temp
folder before attempting to download them.

I'll have to look this over later... trying to get all the little things 
finalized
for the next release tonight.

Original comment by jason.schnitzler on 10 Jun 2009 at 12:43

GoogleCodeExporter commented 8 years ago
What, exactly, are you trying to do here?:

SQLNewcommand.CommandText = String.Concat("SELECT id
FROM movies WHERE path LIKE """, sPath.Substring(0, sPath.Length -
sPath.LastIndexOf(",")), "%"";")

Can't figure that one out. Why is there a comma? Also, you should just be able 
to use
WHERE path = sPath because get nfopath will check if the nfo exists.... if it
doesn't, pass the full movie path.

Need do a little bit of tweaking to it.... something like checking if the source
exists. If not automatically switch to "Offline Mode". Then for 
LoadMovieFromNfo add
an offline mode check. If it and UseNfoCache is enabled then try to get the 
cached
nfo. If offline mode is not enabled, process the nfo as normal, regardless of
UseNfoCache. If offline mode is enabled and UseNfoCache is disabled do nothing.

Original comment by jason.schnitzler on 10 Jun 2009 at 3:18

GoogleCodeExporter commented 8 years ago
Ok let see.. "," comna should be dot "." ;) this is to get the id from db.. 
removing
the nfo part of the path
This is not finished.. i'm working on it.. I post what i have done to see if 
you like
the idea :)
If is ok will keep working on it (in a diferent branch) and send updates whem 
is stable !

Original comment by nfnovais@gmail.com on 10 Jun 2009 at 8:29

GoogleCodeExporter commented 8 years ago
Closed...
Future will include Movie Information on EMM db... this will have no meaning

Original comment by nfnovais@gmail.com on 10 Jun 2009 at 9:12

GoogleCodeExporter commented 8 years ago

Original comment by jason.schnitzler on 14 Jun 2009 at 9:00