コード例 #1
0
ファイル: bookmarks.py プロジェクト: yaoml/quodlibet
 def __check_entry(self, add, time, name):
     try:
         util.parse_time(time.get_text(), None)
     except:
         add.set_sensitive(False)
     else:
         add.set_sensitive(bool(name.get_text()))
コード例 #2
0
ファイル: remote.py プロジェクト: silkecho/glowing-silk
 def _seek(self, time, library, window, player):
     seek_to = player.get_position()
     if time[0] == "+": seek_to += util.parse_time(time[1:]) * 1000
     elif time[0] == "-": seek_to -= util.parse_time(time[1:]) * 1000
     else: seek_to = util.parse_time(time) * 1000
     seek_to = min(player.song.get("~#length", 0) * 1000 -1,
                   max(0, seek_to))
     player.seek(seek_to)
コード例 #3
0
ファイル: commands.py プロジェクト: SimonLarsen/quodlibet
def _seek(app, time):
    player = app.player
    if not player.song:
        return
    seek_to = player.get_position()
    if time[0] == "+":
        seek_to += util.parse_time(time[1:]) * 1000
    elif time[0] == "-":
        seek_to -= util.parse_time(time[1:]) * 1000
    else:
        seek_to = util.parse_time(time) * 1000
    seek_to = min(player.song.get("~#length", 0) * 1000 - 1, max(0, seek_to))
    player.seek(seek_to)
コード例 #4
0
def _seek(app, time):
    player = app.player
    if not player.song:
        return
    seek_to = player.get_position()
    if time[0] == "+":
        seek_to += util.parse_time(time[1:]) * 1000
    elif time[0] == "-":
        seek_to -= util.parse_time(time[1:]) * 1000
    else:
        seek_to = util.parse_time(time) * 1000
    seek_to = min(player.song.get("~#length", 0) * 1000 - 1, max(0, seek_to))
    player.seek(seek_to)
コード例 #5
0
    def bookmarks(self):
        """Parse and return song position bookmarks, or set them.
        Accessing this returns a copy, so song.bookmarks.append(...)
        will not work; you need to do

            marks = song.bookmarks
            marks.append(...)
            song.bookmarks = marks
        """

        marks = []
        invalid = []
        for line in self.list("~bookmark"):
            try:
                time, mark = line.split(" ", 1)
            except:
                invalid.append((-1, line))
            else:
                try:
                    time = util.parse_time(time, None)
                except:
                    invalid.append((-1, line))
                else:
                    if time >= 0:
                        marks.append((time, mark))
                    else:
                        invalid.append((-1, line))
        marks.sort()
        marks.extend(invalid)
        return marks
コード例 #6
0
ファイル: bookmarks.py プロジェクト: yaoml/quodlibet
 def __add(self, model, time, name):
     try:
         time = util.parse_time(time.get_text(), None)
     except:
         pass
     else:
         model.append([time, name.get_text()])
コード例 #7
0
ファイル: bookmarks.py プロジェクト: yaoml/quodlibet
 def __edit_time(self, render, path, new, model):
     try:
         time = util.parse_time(new, None)
     except:
         pass
     else:
         model[path][0] = time
コード例 #8
0
ファイル: _audio.py プロジェクト: elfalem/quodlibet
    def bookmarks(self):
        """Parse and return song position bookmarks, or set them.
        Accessing this returns a copy, so song.bookmarks.append(...)
        will not work; you need to do

            marks = song.bookmarks
            marks.append(...)
            song.bookmarks = marks
        """

        marks = []
        invalid = []
        for line in self.list("~bookmark"):
            try:
                time, mark = line.split(" ", 1)
            except:
                invalid.append((-1, line))
            else:
                try:
                    time = util.parse_time(time, None)
                except:
                    invalid.append((-1, line))
                else:
                    if time >= 0:
                        marks.append((time, mark))
                    else:
                        invalid.append((-1, line))
        marks.sort()
        marks.extend(invalid)
        return marks
コード例 #9
0
ファイル: audiofeeds.py プロジェクト: silkecho/glowing-silk
    def __fill_af(feed, af):
        try: af["title"] = feed.title or _("Unknown")
        except: af["title"] = _("Unknown")
        try: af["date"] = "%04d-%02d-%02d" % feed.modified_parsed[:3]
        except (AttributeError, TypeError): pass

        for songkey, feedkey in [
            ("website", "link"),
            ("description", "tagline"),
            ("language", "language"),
            ("copyright", "copyright"),
            ("organization", "publisher"),
            ("license", "license")]:
            try: value = getattr(feed, feedkey)
            except: pass
            else:
                if value and value not in af.list(songkey):
                    af.add(songkey, value)

        try: author = feed.author_detail
        except AttributeError:
            try: author = feed.author
            except AttributeError: pass
            else:
                if author and author not in af.list("artist"):
                    af.add('artist', author)
        else:
            try:
                if author.email and author.email not in af.list("contact"):
                    af.add("contact", author.email)
            except AttributeError: pass
            try:
                if author.name and author.name not in af.list("artist"):
                    af.add("artist", author.name)
            except AttributeError: pass

        try: values = feed.contributors
        except AttributeError: pass
        else:
            for value in values:
                try: value = value.name
                except AttributeError: pass
                else:
                    if value and value not in af.list("performer"):
                        af.add("performer", value)

        try: af["~#length"] = util.parse_time(feed.itunes_duration)
        except (AttributeError, ValueError): pass

        try: values = dict(feed.categories).values()
        except AttributeError: pass
        else:
            for value in values:
                if value and value not in af.list("genre"):
                    af.add("genre", value)
コード例 #10
0
ファイル: _audio.py プロジェクト: silkecho/glowing-silk
 def __get_bookmarks(self):
     marks = []
     invalid = []
     for line in self.list("~bookmark"):
         try: time, mark = line.split(" ", 1)
         except: invalid.append((-1, line))
         else:
             try: time = util.parse_time(time, None)
             except: invalid.append((-1, line))
             else:
                 if time >= 0: marks.append((time, mark))
                 else: invalid.append((-1, line))
     marks.sort()
     marks.extend(invalid)
     return marks
コード例 #11
0
ファイル: _audio.py プロジェクト: ch1huizong/scode
 def __get_bookmarks(self):
     marks = []
     invalid = []
     for line in self.list("~bookmark"):
         try:
             time, mark = line.split(" ", 1)
         except:
             invalid.append((-1, line))
         else:
             try:
                 time = util.parse_time(time, None)
             except:
                 invalid.append((-1, line))
             else:
                 if time >= 0:
                     marks.append((time, mark))
                 else:
                     invalid.append((-1, line))
     marks.sort()
     marks.extend(invalid)
     return marks
コード例 #12
0
 def test_negative(self):
     self.failUnlessEqual(util.parse_time("-2:04"), -124)
コード例 #13
0
 def test_roundtrip(self):
     # The values are the ones tested for Tformat_time, so we know they
     # will be formatted correctly. They're also representative of
     # all the major patterns.
     for i in [0, 59, 60, 60 * 59 + 59, 60 * 60, 60 * 60 + 60 * 59 + 59]:
         self.failUnlessEqual(util.parse_time(util.format_time(i)), i)
コード例 #14
0
 def test_empty(self):
     self.failUnlessEqual(util.parse_time(""), 0)
コード例 #15
0
 def test_invalid(self):
     self.failUnlessEqual(util.parse_time("not a time"), 0)
コード例 #16
0
ファイル: test_util.py プロジェクト: brunob/quodlibet
 def test_invalid(self):
     self.failUnlessEqual(util.parse_time("not a time"), 0)
コード例 #17
0
ファイル: test_util.py プロジェクト: brunob/quodlibet
 def test_empty(self):
     self.failUnlessEqual(util.parse_time(""), 0)
コード例 #18
0
    def __fill_af(feed, af):
        try:
            af["title"] = feed.title or _("Unknown")
        except:
            af["title"] = _("Unknown")
        try:
            af["date"] = "%04d-%02d-%02d" % feed.modified_parsed[:3]
        except (AttributeError, TypeError):
            pass

        for songkey, feedkey in [
                ("website", "link"),
                ("description", "tagline"),
                ("language", "language"),
                ("copyright", "copyright"),
                ("organization", "publisher"),
                ("license", "license")]:
            try:
                value = getattr(feed, feedkey)
            except:
                pass
            else:
                if value and value not in af.list(songkey):
                    af.add(songkey, value)

        try:
            author = feed.author_detail
        except AttributeError:
            try:
                author = feed.author
            except AttributeError:
                pass
            else:
                if author and author not in af.list("artist"):
                    af.add('artist', author)
        else:
            try:
                if author.email and author.email not in af.list("contact"):
                    af.add("contact", author.email)
            except AttributeError:
                pass
            try:
                if author.name and author.name not in af.list("artist"):
                    af.add("artist", author.name)
            except AttributeError:
                pass

        try:
            values = feed.contributors
        except AttributeError:
            pass
        else:
            for value in values:
                try:
                    value = value.name
                except AttributeError:
                    pass
                else:
                    if value and value not in af.list("performer"):
                        af.add("performer", value)

        try:
            af["~#length"] = util.parse_time(feed.itunes_duration)
        except (AttributeError, ValueError):
            pass

        try:
            values = dict(feed.categories).values()
        except AttributeError:
            pass
        else:
            for value in values:
                if value and value not in af.list("genre"):
                    af.add("genre", value)
コード例 #19
0
ファイル: test_util.py プロジェクト: brunob/quodlibet
 def test_negative(self):
     self.failUnlessEqual(util.parse_time("-2:04"), -124)
コード例 #20
0
ファイル: test_util.py プロジェクト: brunob/quodlibet
 def test_roundtrip(self):
     # The values are the ones tested for Tformat_time, so we know they
     # will be formatted correctly. They're also representative of
     # all the major patterns.
     for i in [0, 59, 60, 60 * 59 + 59, 60 * 60, 60 * 60 + 60 * 59 + 59]:
         self.failUnlessEqual(util.parse_time(util.format_time(i)), i)