Ticket #5569: rmMetadata.patch

File rmMetadata.patch, 853 bytes (added by Robin Neatherway <robthebob+mythtv@…>, 16 years ago)
  • MythVideo.py

     
    194194                        c.execute(sql, sql_values)
    195195                        c.close()
    196196
     197        def rmMetadata(self, video):
     198                """
     199                Removes the metadata for a given id from the database.
     200
     201                Accepts either a videopath as a str, or an id as an int.
     202               
     203                Has no effect if it does not exist.
     204                """
     205                c = self.db.cursor()
     206
     207                if isinstance(video, str):
     208                        c.execute("""
     209                                        DELETE FROM videometadata
     210                                        WHERE filename = %s""", (video,))
     211                elif isinstance(video, int):
     212                        c.execute("""
     213                                        DELETE FROM videometadata
     214                                        WHERE intid = %s""", (video,))
     215                else:
     216                        log.Msg(WARNING, "Attempt to delete non-str, non-int item" +
     217                                                         "from videometadata: %s" % str(video))
     218
     219                c.close()
     220
    197221# vim: ts=4 sw=4: