Exemplo n.º 1
0
def item(link=None):
    if not link:
        raise APIError("Item URL must be defined")
    results = playitem.PlayItemList()
    title = link
    if len(title) > 30:
        title = title[:30] + "..."
    img = '/img/icons/file-o.svg'
    if chanutils.torrent.is_torrent(link):
        link = chanutils.torrent.set_torridx(link)
    results.add(playitem.PlayItem(title, img, link))
    return results.to_dict()
Exemplo n.º 2
0
def get(plid=None):
    if plid is None:
        raise ApiError("Playlist ID must be defined")
    playlist = json.load(open(_get_path(plid), 'r'))
    if not playlist:
        playlist = _empty_playlist()
    playlist['plid'] = plid
    results = playitem.PlayItemList()
    itemnum = 0
    for item in playlist['items']:
        results.add(playitem.PlaylistItem(item, plid, itemnum))
        itemnum = itemnum + 1
    playlist['items'] = results.to_dict()
    return playlist
Exemplo n.º 3
0
def showmore(link):
  files = torrent_files(link)
  if not files:
    raise Exception("Unable to retrieve torrent files")
  results = playitem.PlayItemList()
  idx = 0
  for f in files:
    subtitle = ''
    if isinstance(f[1], basestring):
      subtitle = 'Size: ' + f[1]
    else:
      subtitle = 'Size: ' + chanutils.byte_size(f[1])
    url = set_torridx(link, idx)
    img = '/img/icons/file-o.svg'
    idx = idx + 1
    item = playitem.PlayItem(f[0], img, url, subtitle)
    results.add(item)
  return results
Exemplo n.º 4
0
def _extract(data, moviesubs):
  results = playitem.PlayItemList()
  if not 'data' in data or len(data['data']['children']) == 0:
    return results
  rtree = data['data']['children']
  for r in rtree:
    r = r['data']
    # Internal reddit question/discussion
    if r['is_self']:
      continue
    thumb = None
    if r['thumbnail'] and r['thumbnail'].find('/') > -1:
      thumb = r['thumbnail']
    subtitle = "Score: " + str(r['score'])
    comments = "<a target='_blank' href='http://reddit.com" + r['permalink'] + "'>Comments:" + str(r['num_comments']) + "</a>" 
    subtitle = subtitle + ", " + comments
    title = chanutils.replace_entity(r['title'])
    url = chanutils.replace_entity(r['url'])
    subs = None
    if moviesubs:
      subs = chanutils.movie_title_year(title)
    item = playitem.PlayItem(title, thumb, url, subtitle, subs=subs)
    results.add(item)
  return results