Retrieves the list of tv series the current user has flagged as favorite.

        :return: a python dictionary with either the result of the search or an error from TheTVDB.
14613
def get_user_favorites(self):
        

        return self.parse_raw_response(requests_util.run_request('get', self.API_BASE_URL + '/user/favorites',
                                                                 headers=self.__get_header_with_auth()))
1102568
def _get_video_id(self, url=None):
        
        if url:
            html_data = self.http.request("get", url).text
        else:
            html_data = self.get_urldata()
        html_data = self.get_urldata()
        match = re.search(r'data-video-id="([0-9]+)"', html_data)
        if match:
            return match.group(1)
        match = re.search(r'data-videoid="([0-9]+)', html_data)
        if match:
            return match.group(1)
        match = re.search(r'"mediaGuid":"([0-9]+)"', html_data)
        if match:
            return match.group(1)

        clips = False
        slug = None
        match = re.search('params":({.*}),"query', self.get_urldata())
        if match:
            jansson = json.loads(match.group(1))
            if "seasonNumberOrVideoId" in jansson:
                season = jansson["seasonNumberOrVideoId"]
                match = re.search(r"\w-(\d+)$", season)
                if match:
                    season = match.group(1)
            else:
                match = self._conentpage(self.get_urldata())
                if match:  # this only happen on the program page?
                    janson2 = json.loads(match.group(1))
                    if janson2["formatPage"]["format"]:
                        season = janson2["formatPage"]["format"]["seasonNumber"]
                        return janson2["formatPage"]["format"]["videos"][str(season)]["program"][0]["id"]
                return None
            if "videoIdOrEpisodeNumber" in jansson:
                videp = jansson["videoIdOrEpisodeNumber"]
                match = re.search(r'(\w+)-(\d+)', videp)
                if match:
                    episodenr = match.group(2)
                else:
                    episodenr = videp
                    clips = True
                match = re.search(r'(s\w+)-(\d+)', season)
                if match:
                    season = match.group(2)
            else:
                # sometimes videoIdOrEpisodeNumber does not work.. this is a workaround
                match = re.search(r'(episode|avsnitt)-(\d+)', self.url)
                if match:
                    episodenr = match.group(2)
                else:
                    episodenr = season
            if "slug" in jansson:
                slug = jansson["slug"]

            if clips:
                return episodenr
            else:
                match = self._conentpage(self.get_urldata())
                if match:
                    janson = json.loads(match.group(1))
                    for i in janson["formatPage"]["format"]["videos"].keys():
                        if "program" in janson["formatPage"]["format"]["videos"][str(i)]:
                            for n in janson["formatPage"]["format"]["videos"][i]["program"]:
                                if str(n["episodeNumber"]) and int(episodenr) == n["episodeNumber"] and int(season) == n["seasonNumber"]:
                                    if slug is None or slug == n["formatSlug"]:
                                        return n["id"]
                                elif n["id"] == episodenr:
                                    return episodenr

        parse = urlparse(self.url)
        match = re.search(r'/\w+/(\d+)', parse.path)
        if match:
            return match.group(1)
        match = re.search(r'iframe src="http://play.juicyplay.se[^\"]+id=(\d+)', html_data)
        if match:
            return match.group(1)

        match = re.search(r'<meta property="og:image" content="([\S]+)"', html_data)
        if match:
            return match.group(1).split("/")[-2]

        return None
227097
def get_channel_listing(self):
        
        return {'name': self.name,
                'key': self.channel.key,
                'type': self.channel.typ,
                'read_only': self.read_only,
                'is_online': self.is_online(),
                'actions': self.get_actions(),
                'unread': self.unread_count()}
70755
def get_favoritable_value
      if spree_current_user.present?
        @favorite = spree_current_user.favorites.where(favoritable_params).first
      end

      respond_to do |format|
        format.js
      end
    end
984315
def to_identifier(self):
        

        return {
            'number': self.pk,
            'episodes': [
                episode.to_dict()
                for episode in self.episodes.values()
            ]
        }
685739
def fav_songs(self):
        
        if self._fav_songs is None:
            songs_data = self._api.user_favorite_songs(self.identifier)
            self._fav_songs = []
            if not songs_data:
                return
            for song_data in songs_data:
                song = _deserialize(song_data, NestedSongSchema)
                self._fav_songs.append(song)
        return self._fav_songs
1071438
def get_episode_ids(self, show_id, season):
        
        # get the page of the season of the show
        logger.info('Getting the page of show id %d, season %d', show_id, season)
        r = self.session.get(self.server_url + 'tvshow-%d-%d.html' % (show_id, season), timeout=10)
        soup = ParserBeautifulSoup(r.content, ['lxml', 'html.parser'])

        # loop over episode rows
        episode_ids = {}
        for row in soup.select('table#table5 tr'):
            # skip rows that do not have a link to the episode page
            if not row('a', href=episode_id_re):
                continue

            # extract data from the cells
            cells = row('td')
            episode = int(cells[0].text.split('x')[1])
            episode_id = int(cells[1].a['href'][8:-5])
            episode_ids[episode] = episode_id

        if episode_ids:
            logger.debug('Found episode ids %r', episode_ids)
        else:
            logger.warning('No episode ids found')

        return episode_ids
210135
def get_ratings(data):
    """"""
    episodes = data['episodes']
    ratings = {}
    for season in episodes:
        ratings[season] = collapse(episodes[season])
    return co.OrderedDict(sorted(ratings.items()))
287752
def recommend(self, userid, user_items,
                  N=10, filter_already_liked_items=True, filter_items=None, recalculate_user=False):
        
        if userid >= user_items.shape[0]:
            raise ValueError("userid is out of bounds of the user_items matrix")

        # recalculate_user is ignored because this is not a model based algorithm
        items = N
        if filter_items:
            items += len(filter_items)

        indices, data = self.scorer.recommend(userid, user_items.indptr, user_items.indices,
                                              user_items.data, K=items,
                                              remove_own_likes=filter_already_liked_items)
        best = sorted(zip(indices, data), key=lambda x: -x[1])

        if not filter_items:
            return best

        liked = set(filter_items)
        return list(itertools.islice((rec for rec in best if rec[0] not in liked), N))
1356856
def _filter_subinfo_list(cls, subinfo_list, videoinfo, languages, exts):
        
        filter_field_list = [
            'season',
            'episode',
            'resolution',
            'source',
            'video_encoding',
            'audio_encoding'
        ]
        filtered_subinfo_list = dict((f, []) for f in filter_field_list)
        
        for subinfo in subinfo_list:
            title = subinfo.get('title')
            videoinfo_ = cls._parse_videoname(title)
            last_field = None
            for field in filter_field_list:
                if videoinfo.get(field) == videoinfo_.get(field):
                    last_field = field
                else:
                    break
            if last_field is not None:
                filtered_subinfo_list[last_field].append(subinfo)
        for field in filter_field_list[::-1]:
            if len(filtered_subinfo_list[field]) > 0:
                # sort by download_count and rate
                sorted_subinfo_list = sorted(filtered_subinfo_list[field],
                                     key=lambda item: (
                                         item['rate'], item['download_count']),
                                     reverse=True)
                return sorted_subinfo_list[0]
        return None
835123
public SearchResult<Target> getPersonalFavorites(int limit) throws WorkspaceApiException {
        try {
            TargetsResponse resp = targetsApi.getPersonalFavorites(limit > 0? new BigDecimal(limit): null);
            Util.throwIfNotOk(resp.getStatus());
            
            TargetsResponseData data = resp.getData();
            int total = 0;
            List<Target> list = new ArrayList<>();
            if(data != null) {
                total = data.getTotalMatches();
                if(data.getTargets() != null) {
                    for (com.genesys.internal.workspace.model.Target t : data.getTargets()) {
                        Target target = Target.fromTarget(t);
                        list.add(target);
                    }
                }
            }

            return new SearchResult<>(total, list);
        }
        catch(ApiException ex) {
            throw new WorkspaceApiException("Cannot personal favorites", ex);
        }
    }
350913
public function favorite() : void
    {
        $data = (object)[
            'favoriteDetail' => (object)[
                'favoriteFlag' => true
            ]
        ];

        $this->putJson(sprintf(self::MESSAGE_THREAD_ENDPOINT . 'users/me/threads/%s/favorites', $this->messageThreadId), $data);
    }
733322
def to_dict(self):
        

        result = self.to_identifier()

        result.update({
            'watched': 1 if self.is_watched else 0,
            'collected': 1 if self.is_collected else 0,

            'plays': self.plays if self.plays is not None else 0,
            'in_watchlist': self.in_watchlist if self.in_watchlist is not None else 0,
            'progress': self.progress,

            'last_watched_at': to_iso8601_datetime(self.last_watched_at),
            'collected_at': to_iso8601_datetime(self.collected_at),
            'paused_at': to_iso8601_datetime(self.paused_at)
        })

        if self.rating:
            result['rating'] = self.rating.value
            result['rated_at'] = to_iso8601_datetime(self.rating.timestamp)

        # Extended Info
        if self.released:
            result['released'] = to_iso8601_date(self.released)

        if self.updated_at:
            result['updated_at'] = to_iso8601_datetime(self.updated_at)

        if self.overview:
            result['overview'] = self.overview

        if self.tagline:
            result['tagline'] = self.tagline

        if self.runtime:
            result['runtime'] = self.runtime

        if self.certification:
            result['certification'] = self.certification

        if self.homepage:
            result['homepage'] = self.homepage

        if self.trailer:
            result['trailer'] = self.trailer

        if self.language:
            result['language'] = self.language

        if self.available_translations:
            result['available_translations'] = self.available_translations

        if self.genres:
            result['genres'] = self.genres

        return result
637668
def search(self, user_nick, collect_type, page_no, session=None):
        ''''''
        request = TOPRequest('taobao.favorite.search')
        request['user_nick'] = user_nick
        request['collect_type'] = collect_type
        request['page_no'] = page_no
        self.create(self.execute(request, session))
        return self.result
553001
def get_series_by_id(self, series_id):
        
        try:
            return self.api.get_series(series_id), None
        except exceptions.TVDBRequestException as err:
            LOG.exception('search for series %s failed', series_id)
            return None, _as_str(err)
838221
def to_dict(self):
        

        result = self.to_identifier()

        result.update({
            'ids': dict([
                (key, value) for (key, value) in self.keys[1:]  # NOTE: keys[0] is the season identifier
            ])
        })

        if self.rating:
            result['rating'] = self.rating.value
            result['rated_at'] = to_iso8601_datetime(self.rating.timestamp)

        result['in_watchlist'] = self.in_watchlist if self.in_watchlist is not None else 0

        # Extended Info
        if self.first_aired:
            result['first_aired'] = to_iso8601_datetime(self.first_aired)

        if self.episode_count:
            result['episode_count'] = self.episode_count

        if self.aired_episodes:
            result['aired_episodes'] = self.aired_episodes

        return result
104111
private function getFavorite()
    {
        $favorite = $this->_parser->find('#content table tr', 0)->find('td', 0)->plaintext;
        preg_match('/(Member Favorites: ).+/', $favorite, $parsed_favorite);
        $favorite = trim($parsed_favorite[0]);
        $parsed_favorite = explode(': ', $favorite);

        return str_replace(',', '', $parsed_favorite[1]);
    }