コード例 #1
0
 def __init__(self, api, id, series_id):
     super(Group, self).__init__()
     self.mkdentry(b"torrent", GroupTorrentByKey(api, id))
     self.mkdentry(
         b"series",
         yatfs_fs.StaticSymlink(
             ("../../../series/by-id/%s" % series_id).encode()))
     self.mkdentry(b"category", GroupCategory(api, id))
     self.mkdentry(b"name", GroupName(api, id))
コード例 #2
0
 def __init__(self, backend, api, id, group_id):
     super(Torrent, self).__init__()
     self.api = api
     self.id = id
     self.mkdentry(b"data", TorrentDataContainer(backend, api, id))
     group_link = yatfs_fs.StaticSymlink(
         ("../../../group/by-id/%s" % group_id).encode())
     apply_attr(group_link, api, id)
     self.mkdentry(b"group", group_link)
     self.mkdentry(b"seeders", TorrentSeeders(api, id))
     self.mkdentry(b"leechers", TorrentLeechers(api, id))
     self.mkdentry(b"time", TorrentTime(api, id))
     self.mkdentry(b"release_name", TorrentReleaseName(api, id))
コード例 #3
0
 def lookup_create(self, name):
     try:
         info_hash = name.decode()
     except UnicodeDecodeError:
         raise llfuse.FUSEError(errno.ENOENT)
     c = self.api.db.cursor()
     r = c.execute(
         "select id from torrent_entry where info_hash = ? "
         "and not deleted", (info_hash.upper(), )).fetchone()
     if not r:
         raise llfuse.FUSEError(errno.ENOENT)
     id, = r
     link = yatfs_fs.StaticSymlink(("../by-id/%s" % id).encode())
     apply_attr(link, self.api, id)
     return link
コード例 #4
0
 def lookup_create(self, name):
     try:
         imdb_id = name.decode()
     except UnicodeDecodeError:
         raise fusell.FUSEError(errno.ENOENT)
     c = self.api.db.cursor()
     r = c.execute(
         "select id from series where imdb_id = ? and not deleted",
         (imdb_id, )).fetchone()
     if not r:
         raise llfuse.FUSEError(errno.ENOENT)
     id = r[0]
     link = yatfs_fs.StaticSymlink(("../by-id/%d" % id).encode())
     link.entry_timeout = 3600
     link.attr_timeout = 86400
     return link
コード例 #5
0
 def lookup_create(self, name):
     try:
         name = name.decode()
     except UnicodeDecodeError:
         raise llfuse.FUSEError(errno.ENOENT)
     for name in slash_variations(name):
         c = self.api.db.cursor()
         r = c.execute(
             "select id from series where name = ? and not deleted",
             (name, )).fetchone()
         if not r:
             continue
         id = r[0]
         link = yatfs_fs.StaticSymlink(("../by-id/%d" % id).encode())
         link.entry_timeout = 3600
         link.attr_timeout = 86400
         return link
     else:
         raise llfuse.FUSEError(errno.ENOENT)
コード例 #6
0
 def lookup_create(self, name):
     try:
         name = name.decode()
     except UnicodeDecodeError:
         raise llfuse.FUSEError(errno.ENOENT)
     id = name.split(".")[-1]
     try:
         id = int(id)
     except ValueError:
         raise llfuse.FUSEError(errno.ENOENT)
     c = self.api.db.cursor()
     r = c.execute("select group_id from torrent_entry where id = ?",
                   (id, )).fetchone()
     if (not r) or r[0] != self.id:
         raise llfuse.FUSEError(errno.ENOENT)
     link = yatfs_fs.StaticSymlink(
         ("../../../../torrent/by-id/%d" % id).encode())
     link.entry_timeout = 3600
     link.attr_timeout = 86400
     apply_attr(link, self.api, id)
     return link
コード例 #7
0
 def lookup_create(self, name):
     if self.prefix:
         path = self.prefix + b"/" + name
     else:
         path = name
     c = self.api.db.cursor()
     r = c.execute(
         "select file_info.id, file_info.file_index from file_info "
         "inner join torrent_entry "
         "where file_info.id = torrent_entry.id and "
         "not torrent_entry.deleted and "
         "torrent_entry.group_id = ? "
         "and file_info.path = ?", (
             self.id,
             path,
         )).fetchone()
     if r:
         torrent_entry_id, file_index, = r
         count = path.count(b"/")
         path = ("".join(["../"] * count) +
                 "../../../torrent/by-id/%s/data/by-index/%s" %
                 (torrent_entry_id, file_index))
         link = yatfs_fs.StaticSymlink(path.encode())
         apply_attr(link, self.api, torrent_entry_id)
         return link
     lo = path + b"/"
     hi = path + b"0"
     c = self.api.db.cursor()
     r = c.execute(
         "select count(*) from file_info inner join torrent_entry "
         "where file_info.id = torrent_entry.id and "
         "not torrent_entry.deleted and "
         "torrent_entry.group_id = ? "
         "and file_info.path > ? and file_info.path < ?",
         (self.id, lo, hi)).fetchone()
     count, = r
     if count:
         return GroupBrowseSubdir(self.api, self.id, path)
     raise llfuse.FUSEError(errno.ENOENT)