def toHtml(self): timestamp = datetime.datetime.fromtimestamp( self.timestamp).strftime("%A, %Y-%m-%d %H:%M") if self.duration: timestamp += " (" + unicode(self.duration) + " min)" return u"<b>{}</b><br/><i>{}</i><br/>".format(utils.html(timestamp), utils.html(self.channel))
def get_filtered_programs(dialectId, genreId, typeId): url = URL_FILTER.format(dialect=dialectId, genre=genreId, type=typeId, limit=MAX_LIMIT) html_response = html(url) items = html_response.find('ul').findAll('a', {'class': 'tip_anchor'}) items = html_response.findAll('li') return [_get_program_item(clip) for clip in items]
def get_latest(mediaType): ''' Deprecated. Using Shahid.Net API to fetch the latest media items by different media types ''' url = URL_LATEST.format(operation=LATEST_MAP[mediaType], offset='0', maxLimit=MAX_LIMIT) response = html(url) return response
def get_most_watched(programType): url = URL_MOST_WATCHED.format(operation=MOST_WATCHED_MAP[programType], offset='0', maxLimit=MAX_LIMIT) html_response = html(url) items = html_response.find('ul').findAll('a', {'class': 'tip_anchor'}) return [_get_item(clip, programType) for clip in items]
def toHtml(self): result = u""" <h1>{title}</h1> <p>{schedules}</p> """.format(title=utils.html(self.title), schedules=u"\n".join( [schedule.toHtml() for schedule in self.schedules])) notes = [ note for note in [self.description, self.content, self.hint] if note ] for note in notes: result += u"<p>{}</p>\n".format(utils.html(note)) return result