MCPcopy
hub / github.com/beetbox/beets / load

Method load

beets/util/m3u.py:41–59  ·  view source on GitHub ↗

Reads the m3u file from disk and sets the object's attributes.

(self)

Source from the content-addressed store, hash-verified

39 self.media_list = []
40
41 def load(self):
42 """Reads the m3u file from disk and sets the object's attributes."""
43 pl_normpath = normpath(self.path)
44 try:
45 with open(syspath(pl_normpath), "rb") as pl_file:
46 raw_contents = pl_file.readlines()
47 except OSError as exc:
48 raise FilesystemError(
49 exc, "read", (pl_normpath,), traceback.format_exc()
50 )
51
52 self.extm3u = True if raw_contents[0].rstrip() == b"#EXTM3U" else False
53 for line in raw_contents[1:]:
54 if line.startswith(b"#"):
55 # Support for specific EXTM3U comments could be added here.
56 continue
57 self.media_list.append(normpath(line.rstrip()))
58 if not self.media_list:
59 raise EmptyPlaylistError
60
61 def set_contents(self, media_list, extm3u=True):
62 """Sets self.media_list to a list of media file paths.

Calls 3

normpathFunction · 0.90
syspathFunction · 0.90
FilesystemErrorClass · 0.90