Example #1
0
def SearchMusicAudioTracks(title, query, page, **params):
    oc = ObjectContainer(title2=unicode(L(title)))

    page = int(page)
    limit = common.get_elements_per_page()
    offset = (page-1)*limit

    response = service.search_audio_track(q=query, limit=common.get_elements_per_page(), offset=offset)

    for media in response['objects']:
        title = media['title']
        thumb = 'thumb'
        file = media['file']
        if media['album']['artist']:
            artist = media['album']['artist']['title']
        else:
            artist = ''

        format = 'mp3'
        url = service.BASE_URL + file

        oc.add(GetAudioTrack(title=unicode(title), thumb=thumb, artist=artist, format=format, url=url))

    common.add_pagination_to_response(response, page)
    pagination.append_controls(oc, response, callback=SearchMusicAudioTracks, title=title, query=query, page=page, **params)

    return oc
Example #2
0
def HandleArtists(title, page=1, **params):
    oc = ObjectContainer(title2=unicode(L(title)))

    page = int(page)
    limit = util.get_elements_per_page()
    offset = (page - 1) * limit

    response = service.get_artists(limit=limit, offset=offset, **params)

    oc.title2 = unicode(L(title)) + ' (' + str(
        response['meta']['total_count']) + ')'

    for artist in BuildArtistsList(response['objects']):
        oc.add(artist)

    service.add_pagination_to_response(response, page,
                                       util.get_elements_per_page())
    pagination.append_controls(oc,
                               response['data'],
                               callback=HandleArtists,
                               title=title,
                               page=page)

    oc.add(
        InputDirectoryObject(key=Callback(SearchArtists,
                                          title=unicode(L("Artists Search"))),
                             title=unicode(L("Artists Search")),
                             thumb=R(SEARCH_ICON)))

    return oc
Example #3
0
def HandlePerformersLetterGroup(letter, page=1):
    oc = ObjectContainer(title2=unicode(L(letter)))

    if letter == "Все":
        response = service.get_performers(page=page)

        for item in response['items']:
            name = item['name']
            url = item['path']

            oc.add(DirectoryObject(
                key=Callback(HandlePerformer, type='performer', url=url, name=name),
                title=unicode(name)
            ))

        pagination.append_controls(oc, response['pagination'], page=page, callback=HandlePerformersLetterGroup, letter=letter)
    else:
        for group_name, group in performers.iteritems():
            if group_name.find(letter) == 0:
                oc.add(DirectoryObject(
                    key=Callback(HandlePerformersLetter, name=group_name, items=group),
                    title=group_name
                ))

    return oc
Example #4
0
def HandleAlbums(title, page=1, **params):
    oc = ObjectContainer(title2=unicode(L(title)))

    page = int(page)
    limit = common.get_elements_per_page()
    offset = (page - 1) * limit

    response = service.get_albums(limit=limit,
                                  offset=offset,
                                  year__gte=common.get_start_music_year(),
                                  year__lte=common.get_end_music_year(),
                                  **params)

    oc.title2 = unicode(L(title)) + ' (' + str(
        response['meta']['total_count']) + ')'

    for media in BuildAlbumsList(response['objects']):
        oc.add(media)

    oc.add(
        InputDirectoryObject(key=Callback(SearchMusicAlbums,
                                          title=unicode(L("Albums Search")),
                                          page=page),
                             title=unicode(L("Albums Search")),
                             thumb=R(SEARCH_ICON)))

    common.add_pagination_to_response(response, page)
    pagination.append_controls(oc,
                               response,
                               callback=HandleAlbums,
                               title=title,
                               page=page,
                               **params)

    return oc
Example #5
0
def HandleCollections(title, page=1):
    oc = ObjectContainer()

    page = int(page)
    limit = util.get_elements_per_page()
    offset = (page-1)*limit

    response = service.get_collections(limit=limit, offset=offset)

    oc.title2 = unicode(L('Collections')) + ' (' + str(response['meta']['total_count']) + ')'

    for media in response['objects']:
        name = media['title']
        thumb = media['thumbnail']

        new_params = {
            'type': 'collection',
            'id': media['id'],
            'collection__id': media['id'],
            'name': name,
            'thumb': thumb
        }
        key = Callback(HandleCollection, **new_params)
        oc.add(DirectoryObject(key=key, title=unicode(name), thumb=thumb))

    oc.add(InputDirectoryObject(
        key=Callback(SearchCollections, title=unicode(L("Collections Search"))),
        title=unicode(L("Collections Search")),
        thumb=R(SEARCH_ICON)
    ))

    service.add_pagination_to_response(response, page, util.get_elements_per_page())
    pagination.append_controls(oc, response['data'], callback=HandleCollections, title=title, page=page)

    return oc
Example #6
0
def GetLiveChannels(title, favorite_only=False, category=0, page=1, **params):
    page = int(page)

    oc = ObjectContainer(title2=unicode(title))

    response = video_service.get_live_channels(favorite_only=favorite_only, category=category)

    for index, media in enumerate(response["data"]):
        if index >= (page - 1) * common.get_elements_per_page() and index < page * common.get_elements_per_page():
            id = media["id"]
            name = media["name"]
            thumb = media["icon"]
            files = media["files"]

            oc.add(
                DirectoryObject(
                    key=Callback(GetLiveChannel, name=name, channel_id=id, thumb=thumb, files=json.dumps(files)),
                    title=unicode(name),
                    thumb=Resource.ContentsOfURLWithFallback(url=thumb),
                )
            )

    add_pagination_to_response(response, page)
    pagination.append_controls(
        oc, response, callback=GetLiveChannels, title=title, favorite_only=favorite_only, page=page
    )

    return oc
Example #7
0
def HandleMovies(title, id, page=1):
    oc = ObjectContainer(title2=unicode(L(title)))

    response = service.get_movies(path=id, page=page)

    for item in response['items']:
        name = item['name']
        thumb = item['thumb']

        new_params = {
            'id': item['path'],
            'name': item['name'],
            'thumb': item['thumb'],
            'isSerie': item['isSerie']
        }
        oc.add(
            DirectoryObject(key=Callback(HandleMovieOrSerie, **new_params),
                            title=plex_util.sanitize(name),
                            thumb=plex_util.get_thumb(thumb)))

    pagination.append_controls(oc,
                               response,
                               callback=HandleMovies,
                               id=id,
                               title=title,
                               page=page)

    return oc
Example #8
0
def HandleSearch(query=None, page=1):
    oc = ObjectContainer(title2=unicode(L('Search')))

    response = service.search(query=query, page=page)

    for item in response['items']:
        name = item['name']
        thumb = item['thumb']

        new_params = {
            'id': item['path'],
            'title': name,
            'name': name,
            'thumb': thumb,
            'isSerie': item['isSerie']
        }
        oc.add(
            DirectoryObject(key=Callback(HandleMovieOrSerie, **new_params),
                            title=unicode(name),
                            thumb=plex_util.get_thumb(thumb)))

    pagination.append_controls(oc,
                               response,
                               callback=HandleSearch,
                               query=query,
                               page=page)

    return oc
Example #9
0
def HandleSelection(page=1, operation=None, **params):
    oc = ObjectContainer(title2=unicode(params['name']))

    media_info = MediaInfo(**params)

    service.queue.handle_bookmark_operation(operation, media_info)

    response = service.get_selection(params['id'], page=page)

    for item in response['movies']:
        new_params = {
            'type': 'movie',
            'id': item['path'],
            'name': item['name'],
            'thumb': item['thumb'],
        }

        oc.add(DirectoryObject(
            key=Callback(HandleMovie, **new_params),
            title=plex_util.sanitize(item['name']),
            thumb=plex_util.get_thumb(item['thumb'])
        ))

    service.queue.append_bookmark_controls(oc, HandleSelection, media_info)
    pagination.append_controls(oc, response, page=page, callback=HandleSelection, **media_info)

    return oc
Example #10
0
def HandleCriteria(id, name, page=1, per_page=25):
    oc = ObjectContainer(title2=unicode(L(name)))

    response = service.get_movies_by_criteria_paginated(path=id,
                                                        page=page,
                                                        per_page=per_page)

    for item in response['items']:
        name = item['name'] + " - " + item['rating']

        new_params = {
            'id': item['path'],
            'name': item['name'],
            'thumb': 'thumb'
        }
        oc.add(
            DirectoryObject(key=Callback(HandleMovieOrSerie, **new_params),
                            title=name))

    pagination.append_controls(oc,
                               response,
                               callback=HandleCriteria,
                               id=id,
                               name=name,
                               page=page,
                               per_page=per_page)

    return oc
Example #11
0
def HandleCollections(title, page=1, **params):
    oc = ObjectContainer()

    page = int(page)
    limit = common.get_elements_per_page()
    offset = (page-1)*limit

    response = service.get_collections(limit=limit, offset=offset)

    oc.title2 = unicode(L('Collections')) + ' (' + str(response['meta']['total_count']) + ')'

    for media in response['objects']:
        id = media['id']
        name = media['title']
        thumb = media['thumbnail']

        key = Callback(HandleCollection, collection__id=id, title=name, thumb=thumb)
        oc.add(DirectoryObject(key=key, title=unicode(name), thumb=thumb))

    add_search_collections(oc)

    common.add_pagination_to_response(response, page)
    pagination.append_controls(oc, response, callback=HandleCollections, title=title, page=page)

    return oc
Example #12
0
def HandleSelections(page=1):
    oc = ObjectContainer(title2=unicode(L('Selections')))

    response = service.get_selections(page=page)

    for item in response['movies']:
        name = item['name']

        if name != "Актёры и актрисы" and name != "Актеры и актрисы":
            new_params = {
                'type': 'selection',
                'id': item['path'],
                'name': name,
                'thumb': item['thumb'],
            }

            oc.add(DirectoryObject(
                key=Callback(HandleSelection, **new_params),
                title=plex_util.sanitize(name),
                thumb=plex_util.get_thumb(item['thumb'])
            ))

    pagination.append_controls(oc, response, callback=HandleSelections, page=page)

    return oc
Example #13
0
def SearchTracks(title, query, page, **params):
    oc = ObjectContainer(title2=unicode(L(title)))

    page = int(page)
    limit = util.get_elements_per_page()
    offset = (page-1)*limit

    response = service.search_audio_track(q=query, limit=util.get_elements_per_page(), offset=offset)

    for media in response['objects']:
        title = media['title']
        thumb = 'thumb'
        file = media['file']
        if media['album']['artist']:
            artist = media['album']['artist']['title']
        else:
            artist = ''

        format = 'mp3'
        url = service.BASE_URL + file

        new_params = {
            'type': 'track',
            'id': url,
            'name': title,
            'thumb': 'thumb',
            'artist': artist,
            'format': format
        }
        oc.add(HandleTrack(**new_params))

    service.add_pagination_to_response(response, page, util.get_elements_per_page())
    pagination.append_controls(oc, response['data'], callback=SearchTracks, title=title, query=query, page=page, **params)

    return oc
Example #14
0
def HandleMovies(title, path=None, page=1):
    oc = ObjectContainer(title2=unicode(title), view_group='List')

    document = service.fetch_document(service.get_page_url(path, page))

    response = service.get_movies(document, path)

    for movie in response['items']:
        name = movie['name']
        thumb = movie['thumb']

        new_params = {
            'id': movie['path'],
            'title': name,
            'name': name,
            'thumb': thumb
        }

        key = Callback(HandleMovieOrSerie, **new_params)

        oc.add(DirectoryObject(key=key, title=name, thumb=thumb))

    pagination.append_controls(oc, response, page=page, callback=HandleMovies, title=title, path=path)

    return oc
Example #15
0
def HandlePopular(page=1):
    page = int(page)

    oc = ObjectContainer(title2=unicode(L('Popular')))

    response = service.get_popular(page=page)

    for index, item in enumerate(response['items']):
        name = item['title']
        path = item['path']
        thumb = item['thumb']

        new_params = {
            'id': path,
            'title': name,
            'name': name,
            'thumb': thumb
        }
        key = Callback(HandleMovieOrSerie, **new_params)

        oc.add(DirectoryObject(key=key, title=unicode(name), thumb=thumb))

    pagination.append_controls(oc, response, page=int(page), callback=HandlePopular)

    return oc
Example #16
0
def HandleGenre(operation=None, page=1, **params):
    oc = ObjectContainer(title2=unicode(L(params['name'])))

    media_info = MediaInfo(**params)

    service.queue.handle_bookmark_operation(operation, media_info)

    Log(params)

    response = service.get_genre(path=params['id'], page=page)

    for item in response['items']:
        name = item['name']
        id = item['path']
        thumb = item['thumb']

        oc.add(DirectoryObject(
            key=Callback(HandleTracks, type='tracks', id=id, name=name, thumb=thumb),
            title=unicode(name),
            thumb=thumb
        ))

    service.queue.append_bookmark_controls(oc, HandleGenre, media_info)

    pagination.append_controls(oc, response['pagination'], page=page, callback=HandleGenre, name=params['name'], id=params['id'])

    return oc
Example #17
0
def HandleAlbums(title, page=1, **params):
    oc = ObjectContainer(title2=unicode(L(title)))

    page = int(page)
    limit = util.get_elements_per_page()
    offset = (page-1)*limit

    response = service.get_albums(limit=limit, offset=offset,
                                  year__gte=util.get_start_music_year(),
                                  year__lte=util.get_end_music_year(),
                                  **service.filter_request_params(params))

    oc.title2 = unicode(L(title)) + ' (' + str(response['meta']['total_count']) + ')'

    for media in BuildAlbumsList(response['objects']):
        oc.add(media)

    oc.add(InputDirectoryObject(
            key=Callback(SearchAlbums, title=unicode(L("Albums Search")), page=page),
            title=unicode(L("Albums Search")),
            thumb=R(SEARCH_ICON)
    ))

    service.add_pagination_to_response(response, page, util.get_elements_per_page())
    pagination.append_controls(oc, response['data'], callback=HandleAlbums, title=title, page=page, **params)

    return oc
Example #18
0
def HandleAudioTracks(name, thumb, page=1, **params):
    oc = ObjectContainer(title2=unicode(name))

    page = int(page)
    limit = common.get_elements_per_page()
    offset = (page-1)*limit

    response = service.get_tracks(limit=common.get_elements_per_page(), offset=offset, **params)

    for media in response['objects']:
        title = media['title']
        file = media['file']

        if media['album']['artist']:
            artist = media['album']['artist']['title']
        else:
            artist = ''

        format = 'mp3'
        url = service.BASE_URL + file

        oc.add(GetAudioTrack(title=unicode(title), thumb=thumb, artist=artist, format=format, url=url))

    music_queue.append_controls(oc, name=name, thumb=thumb, **params)

    common.add_pagination_to_response(response, page)
    pagination.append_controls(oc, response, callback=HandleAudioTracks, name=name, thumb=thumb, page=page, **params)

    return oc
Example #19
0
def HandleChildren(id, name, thumb, in_queue=False, page=1, dir='desc'):
    oc = ObjectContainer(title2=unicode(name))

    response = video_service.get_children(
        int(id), per_page=common.get_elements_per_page(), page=page, dir=dir)

    for media in HandleMediaList(response['data']['children'],
                                 in_queue=in_queue):
        oc.add(media)

    bookmarks.append_controls(oc, id=id, name=name, thumb=thumb)
    sorting.append_controls(oc,
                            HandleChildren,
                            id=id,
                            name=name,
                            thumb=thumb,
                            in_queue=in_queue,
                            page=page,
                            dir=dir)

    pagination.append_controls(oc,
                               response,
                               callback=HandleChildren,
                               id=id,
                               name=name,
                               thumb=thumb,
                               in_queue=in_queue,
                               page=page,
                               dir=dir)

    return oc
Example #20
0
def GetLiveChannels(title, favorite_only=False, category=0, page=1, **params):
    page = int(page)

    oc = ObjectContainer(title2=unicode(title))

    response = video_service.get_live_channels(favorite_only=favorite_only,
                                               category=category)

    for index, media in enumerate(response['data']):
        if index >= (page - 1) * common.get_elements_per_page(
        ) and index < page * common.get_elements_per_page():
            id = media['id']
            name = media['name']
            thumb = media['icon']
            files = media['files']

            oc.add(
                DirectoryObject(
                    key=Callback(GetLiveChannel,
                                 name=name,
                                 channel_id=id,
                                 thumb=thumb,
                                 files=json.dumps(files)),
                    title=unicode(name),
                    thumb=Resource.ContentsOfURLWithFallback(url=thumb)))

    add_pagination_to_response(response, page)
    pagination.append_controls(oc,
                               response,
                               callback=GetLiveChannels,
                               title=title,
                               favorite_only=favorite_only,
                               page=page)

    return oc
Example #21
0
def HandleSearch(query, page=1):
    oc = ObjectContainer(title2=unicode(L('Search')))

    response = service.search(query=query, page=page)

    for item in response['items']:
        name = item['name']
        id = item['path']
        thumb = item['thumb']
        description = item['description']

        new_params = {
            'type': 'tracks',
            'id': id,
            'name': name,
            'thumb': thumb,
            # 'artist': author,
            'content': description,
            # 'rating': rating
        }
        oc.add(DirectoryObject(
            key=Callback(HandleTracks, **new_params),
            title=unicode(name),
            thumb=thumb
        ))

    pagination.append_controls(oc, response['pagination'], page=page, callback=HandleSearch, query=query)

    return oc
Example #22
0
def HandleCollections(title, page=1, **params):
    oc = ObjectContainer()

    page = int(page)
    limit = common.get_elements_per_page()
    offset = (page - 1) * limit

    response = service.get_collections(limit=limit, offset=offset)

    oc.title2 = unicode(L('Collections')) + ' (' + str(
        response['meta']['total_count']) + ')'

    for media in response['objects']:
        id = media['id']
        name = media['title']
        thumb = media['thumbnail']

        key = Callback(HandleCollection,
                       collection__id=id,
                       title=name,
                       thumb=thumb)
        oc.add(DirectoryObject(key=key, title=unicode(name), thumb=thumb))

    add_search_collections(oc)

    common.add_pagination_to_response(response, page)
    pagination.append_controls(oc,
                               response,
                               callback=HandleCollections,
                               title=title,
                               page=page)

    return oc
Example #23
0
def SearchCollections(title, query, page=1, **params):
    page = int(page)
    limit = util.get_elements_per_page()
    offset = (page - 1) * limit

    oc = ObjectContainer(title2=unicode(L(title)))

    response = service.search_collection(q=query,
                                         limit=util.get_elements_per_page(),
                                         offset=offset)

    for media in BuildArtistsList(response['objects']):
        oc.add(media)

    service.add_pagination_to_response(response, page,
                                       util.get_elements_per_page())
    pagination.append_controls(oc,
                               response['data'],
                               callback=SearchCollections,
                               title=title,
                               query=query,
                               page=page,
                               **params)

    return oc
Example #24
0
def HandleGenre(id, name, page=1, **params):
    oc = ObjectContainer(title2=unicode(name))

    response = video_service.get_archive(genre=int(id), per_page=common.get_elements_per_page(), page=page)

    for media in HandleMediaList(response['data']['media']):
        oc.add(media)

    pagination.append_controls(oc, response, page=page, callback=HandleGenre, id=id, name=name)

    return oc
Example #25
0
def GetHistory(page=1, **params):
    oc = ObjectContainer(title2=unicode(L('History')))

    response = video_service.get_history(per_page=common.get_elements_per_page(), page=page)

    for media in HandleMediaList(response['data']['media']):
        oc.add(media)

    pagination.append_controls(oc, response, page=page, callback=GetHistory)

    return oc
Example #26
0
def HandleTopic(id, page=1, **params):
    oc = ObjectContainer(title2=unicode(L(id)))

    response = video_service.get_topic_items(id, page=page)

    for media in HandleMediaList(response['data']['media']):
        oc.add(media)

    pagination.append_controls(oc, response, callback=HandleTopic, id=id, page=page)

    return oc
Example #27
0
def HandleTracks(operation=None, page=1, **params):
    media_info = MediaInfo(**params)

    if 'album' in params:
        media_info['id'] = params['album']

    service.queue.handle_bookmark_operation(operation, media_info)

    oc = ObjectContainer(title2=unicode(params['name']))

    page = int(page)
    limit = util.get_elements_per_page()
    offset = (page - 1) * limit

    response = service.get_tracks(limit=util.get_elements_per_page(),
                                  offset=offset,
                                  **service.filter_request_params(params))

    for media in response['objects']:
        title = media['title']
        file = media['file']

        if media['album']['artist']:
            artist = media['album']['artist']['title']
        else:
            artist = ''

        format = 'mp3'
        url = service.BASE_URL + file
        bitrate = "128"

        new_params = {
            'type': 'track',
            'id': url,
            'name': title,
            'thumb': params['thumb'],
            'artist': artist,
            'format': format,
            'bitrate': bitrate
        }

        oc.add(HandleTrack(**new_params))

    service.queue.append_bookmark_controls(oc, HandleTracks, media_info)

    service.add_pagination_to_response(response, page,
                                       util.get_elements_per_page())
    pagination.append_controls(oc,
                               response['data'],
                               callback=HandleTracks,
                               page=page,
                               **params)

    return oc
Example #28
0
def HandleChannel(id, name, page=1, **params):
    oc = ObjectContainer(title2=unicode(name))

    response = service.get_archive(channel_id=id, per_page=util.get_elements_per_page(), page=page)

    for media in HandleMediaList(response['data']['media']):
        oc.add(media)

    pagination.append_controls(oc, response['data'], page=page, callback=HandleChannel, id=id, name=name, params=params)

    return oc
Example #29
0
def GetNewArrivals(page=1, **params):
    oc = ObjectContainer(title2=unicode(L('New Arrivals')))

    response = service.get_new_arrivals(per_page=util.get_elements_per_page(), page=page)

    for media in HandleMediaList(response['data']['media']):
        oc.add(media)

    pagination.append_controls(oc, response['data'], page=page, callback=GetNewArrivals)

    return oc
Example #30
0
def GetHistory(page=1, **params):
    oc = ObjectContainer(title2=unicode(L('History')))

    response = video_service.get_history(
        per_page=common.get_elements_per_page(), page=page)

    for media in HandleMediaList(response['data']['media']):
        oc.add(media)

    pagination.append_controls(oc, response, page=page, callback=GetHistory)

    return oc
Example #31
0
def SearchMovies(query=None, page=1, **params):
    response = video_service.search(query=query, per_page=common.get_elements_per_page(), page=page)

    oc = ObjectContainer(title2=unicode(L('Movies Search')))

    for media in HandleMediaList(response['data']['media']):
        oc.add(media)

    pagination.append_controls(oc, response, page=page, callback=SearchMovies, query=query)

    if len(oc) < 1:
        return common.no_contents('Movies Search')

    return oc
Example #32
0
def HandleChildren(id,
                   name,
                   thumb,
                   operation=None,
                   in_queue=False,
                   page=1,
                   dir='desc'):
    oc = ObjectContainer(title2=unicode(name))

    if operation == 'add':
        service.add_bookmark(id)
    elif operation == 'remove':
        service.remove_bookmark(id)

    response = service.get_children(int(id),
                                    per_page=util.get_elements_per_page(),
                                    page=page,
                                    dir=dir)

    for media in HandleMediaList(response['data']['children'],
                                 in_queue=in_queue):
        oc.add(media)

    bookmarks.append_controls(oc,
                              HandleChildren,
                              id=id,
                              name=name,
                              thumb=thumb,
                              operation=operation)
    append_sorting_controls(oc,
                            HandleChildren,
                            id=id,
                            name=name,
                            thumb=thumb,
                            in_queue=in_queue,
                            page=page,
                            dir=dir)

    pagination.append_controls(oc,
                               response['data'],
                               callback=HandleChildren,
                               id=id,
                               name=name,
                               thumb=thumb,
                               in_queue=in_queue,
                               page=page,
                               dir=dir)

    return oc
Example #33
0
def HandleTopic(id, page=1, **params):
    oc = ObjectContainer(title2=unicode(L(id)))

    response = video_service.get_topic_items(id, page=page)

    for media in HandleMediaList(response['data']['media']):
        oc.add(media)

    pagination.append_controls(oc,
                               response,
                               callback=HandleTopic,
                               id=id,
                               page=page)

    return oc
Example #34
0
def GetNewArrivals(page=1, **params):
    oc = ObjectContainer(title2=unicode(L('New Arrivals')))

    response = service.get_new_arrivals(per_page=util.get_elements_per_page(),
                                        page=page)

    for media in HandleMediaList(response['data']['media']):
        oc.add(media)

    pagination.append_controls(oc,
                               response['data'],
                               page=page,
                               callback=GetNewArrivals)

    return oc
Example #35
0
def HandleMovies(page=1):
    oc = ObjectContainer(title1=unicode(L("Movies")))

    response = service.get_movies(page=page)

    for item in response['movies']:
        oc.add(DirectoryObject(
            key=Callback(HandleMovie, name=item['name'], id=item['path'], thumb=item['thumb']),
            title=item['name'],
            thumb=plex_util.get_thumb(item['thumb'])
        ))

    pagination.append_controls(oc, response, callback=HandleMovies, page=page)

    return oc
Example #36
0
def HandleChildren(id, name, thumb, in_queue=False, page=1, dir='desc'):
    oc = ObjectContainer(title2=unicode(name))

    response = video_service.get_children(int(id), per_page=common.get_elements_per_page(), page=page, dir=dir)

    for media in HandleMediaList(response['data']['children'], in_queue=in_queue):
        oc.add(media)

    bookmarks.append_controls(oc, id=id, name=name, thumb=thumb)
    sorting.append_controls(oc, HandleChildren, id=id, name=name, thumb=thumb, in_queue=in_queue, page=page, dir=dir)

    pagination.append_controls(oc, response, callback=HandleChildren, id=id, name=name, thumb=thumb,
                               in_queue=in_queue, page=page, dir=dir)

    return oc
Example #37
0
def HandleTracks(operation=None, page=1, **params):
    media_info = MediaInfo(**params)

    if 'album' in params:
        media_info['id'] = params['album']

    service.queue.handle_bookmark_operation(operation, media_info)

    oc = ObjectContainer(title2=unicode(params['name']))

    page = int(page)
    limit = util.get_elements_per_page()
    offset = (page-1)*limit

    response = service.get_tracks(limit=util.get_elements_per_page(), offset=offset,
                                  **service.filter_request_params(params))

    for media in response['objects']:
        title = media['title']
        file = media['file']

        if media['album']['artist']:
            artist = media['album']['artist']['title']
        else:
            artist = ''

        format = 'mp3'
        url = service.BASE_URL + file
        bitrate = "128"

        new_params = {
            'type': 'track',
            'id': url,
            'name': title,
            'thumb': params['thumb'],
            'artist': artist,
            'format': format,
            'bitrate': bitrate
        }

        oc.add(HandleTrack(**new_params))

    service.queue.append_bookmark_controls(oc, HandleTracks, media_info)

    service.add_pagination_to_response(response, page, util.get_elements_per_page())
    pagination.append_controls(oc, response['data'], callback=HandleTracks, page=page, **params)

    return oc
Example #38
0
def SearchCollections(title, query, page=1, **params):
    page = int(page)
    limit = util.get_elements_per_page()
    offset = (page-1)*limit

    oc = ObjectContainer(title2=unicode(L(title)))

    response = service.search_collection(q=query, limit=util.get_elements_per_page(), offset=offset)

    for media in BuildArtistsList(response['objects']):
        oc.add(media)

    service.add_pagination_to_response(response, page, util.get_elements_per_page())
    pagination.append_controls(oc, response['data'], callback=SearchCollections, title=title, query=query, page=page, **params)

    return oc
Example #39
0
def SearchMusicArtists(title, query, page, **params):
    oc = ObjectContainer(title2=unicode(L(title)))

    page = int(page)
    limit = common.get_elements_per_page()
    offset = (page-1)*limit

    response = service.search_artist_annotated(q=query, limit=common.get_elements_per_page(), offset=offset)

    for artist in BuildArtistsList(response['objects']):
        oc.add(artist)

    common.add_pagination_to_response(response, page)
    pagination.append_controls(oc, response, callback=SearchMusicArtists, title=title, query=query, page=page, **params)

    return oc
Example #40
0
def HandlePerformers(title, page=1):
    oc = ObjectContainer(title2=unicode(L(title)))

    response = service.get_performers(page=page)

    for item in response['items']:
        name = item['name']
        url = item['path']

        oc.add(DirectoryObject(
            key=Callback(HandlePerformer, url=url, name=name),
            title=unicode(name)
        ))

    pagination.append_controls(oc, response['pagination'], page=page, callback=HandlePerformers, title=title)

    return oc
Example #41
0
def HandleMovies(page=1):
    oc = ObjectContainer(title1=unicode(L("Movies")))

    response = service.get_movies(page=page)

    for item in response['movies']:
        oc.add(
            DirectoryObject(key=Callback(HandleMovie,
                                         name=item['name'],
                                         id=item['path'],
                                         thumb=item['thumb']),
                            title=item['name'],
                            thumb=plex_util.get_thumb(item['thumb'])))

    pagination.append_controls(oc, response, callback=HandleMovies, page=page)

    return oc
Example #42
0
def HandleGenre(id, name, page=1, **params):
    oc = ObjectContainer(title2=unicode(name))

    response = video_service.get_archive(
        genre=int(id), per_page=common.get_elements_per_page(), page=page)

    for media in HandleMediaList(response['data']['media']):
        oc.add(media)

    pagination.append_controls(oc,
                               response,
                               page=page,
                               callback=HandleGenre,
                               id=id,
                               name=name)

    return oc
Example #43
0
def HandleLetter(title, page=1, **params):
    oc = ObjectContainer(title2=unicode(title))

    page = int(page)
    limit = common.get_elements_per_page()
    offset = (page-1)*limit

    response = service.get_artist_annotated(limit=limit, offset=offset, **params)

    for artist in BuildArtistsList(response['objects']):
        oc.add(artist)

    common.add_pagination_to_response(response, page)
    pagination.append_controls(oc, response, callback=HandleLetter, title=title, page=page, **params)

    add_search_artists(oc)

    return oc
Example #44
0
def BuildSearchMovies(oc, page, query):
    response = service.search(query=query, page=page)

    for movie in response['items']:
        name = movie['name']
        thumb = movie['thumb']

        new_params = {
            'id': movie['path'],
            'title': name,
            'name': name,
            'thumb': thumb
        }
        key = Callback(HandleMovieOrSerie, **new_params)

        oc.add(DirectoryObject(key=key, title=name, thumb=thumb))

    pagination.append_controls(oc, response, page=page, callback=HandleSearch, query=query)
Example #45
0
def HandleSeries(category_path, title, page=1):
    oc = ObjectContainer(title2=unicode(title))

    response = service.get_subcategories(category_path, page)

    for item in response['data']:
        name = item['title']
        path = item['path']

        oc.add(DirectoryObject(
            key=Callback(HandleCategoryItems, category_path=path, title=name),
            title=unicode(name),
            thumb=R(ICON)
        ))

    pagination.append_controls(oc, response, page=page, callback=HandleSeries, category_path=category_path, title=title)

    return oc
Example #46
0
def SearchTracks(title, query, page, **params):
    oc = ObjectContainer(title2=unicode(L(title)))

    page = int(page)
    limit = util.get_elements_per_page()
    offset = (page - 1) * limit

    response = service.search_audio_track(q=query,
                                          limit=util.get_elements_per_page(),
                                          offset=offset)

    for media in response['objects']:
        title = media['title']
        thumb = 'thumb'
        file = media['file']
        if media['album']['artist']:
            artist = media['album']['artist']['title']
        else:
            artist = ''

        format = 'mp3'
        url = service.BASE_URL + file

        new_params = {
            'type': 'track',
            'id': url,
            'name': title,
            'thumb': 'thumb',
            'artist': artist,
            'format': format
        }
        oc.add(HandleTrack(**new_params))

    service.add_pagination_to_response(response, page,
                                       util.get_elements_per_page())
    pagination.append_controls(oc,
                               response['data'],
                               callback=SearchTracks,
                               title=title,
                               query=query,
                               page=page,
                               **params)

    return oc
Example #47
0
def HandleChannel(id, name, page=1, **params):
    oc = ObjectContainer(title2=unicode(name))

    response = service.get_archive(channel_id=id,
                                   per_page=util.get_elements_per_page(),
                                   page=page)

    for media in HandleMediaList(response['data']['media']):
        oc.add(media)

    pagination.append_controls(oc,
                               response['data'],
                               page=page,
                               callback=HandleChannel,
                               id=id,
                               name=name,
                               params=params)

    return oc
Example #48
0
def HandleGenres(title, page=1):
    oc = ObjectContainer(title2=unicode(L(title)))

    response = service.get_genres(page=page)

    for item in response['items']:
        name = item['name']
        id = item['path']
        thumb = item['thumb']

        oc.add(DirectoryObject(
            key=Callback(HandleGenre, type='genre', name=name, id=id),
            title=unicode(name),
            thumb=thumb
        ))

    pagination.append_controls(oc, response['pagination'], page=page, callback=HandleGenres, title=title)

    return oc
Example #49
0
def HandleCategoryItems(category_path, title, page=1):
    response = service.get_category_items(category_path, page)

    if len(response['items']) == 1:
        item = response['items'][0]

        name = item['title']
        path = item['path']
        thumb = service.get_thumb(item['thumb'])

        new_params = {
            'id': path,
            'title': name,
            'name': name,
            'thumb': thumb
        }
        return HandleMovieOrSerie(**new_params)
    else:
        oc = ObjectContainer(title2=unicode(title))

        if response['items']:
            for item in response['items']:
                name = item['title']
                path = item['path']
                thumb = service.get_thumb(item['thumb'])

                new_params = {
                    'id': path,
                    'title': name,
                    'name': name,
                    'thumb': thumb
                }

                oc.add(DirectoryObject(
                    key=Callback(HandleMovieOrSerie, **new_params),
                    title=plex_util.sanitize(name),
                    thumb=thumb
                ))

            pagination.append_controls(oc, response, page=page, callback=HandleCategoryItems, title=title,
                                       category_path=category_path)

        return oc
Example #50
0
def HandleCategoryItems(category_path, title, page=1):
    response = service.get_category_items(category_path, page)

    if len(response['items']) == 1:
        item = response['items'][0]

        name = item['title']
        path = item['path']
        thumb = service.get_thumb(item['thumb'])

        new_params = {'id': path, 'title': name, 'name': name, 'thumb': thumb}
        return HandleMovieOrSerie(**new_params)
    else:
        oc = ObjectContainer(title2=unicode(title))

        if response['items']:
            for item in response['items']:
                name = item['title']
                path = item['path']
                thumb = service.get_thumb(item['thumb'])

                new_params = {
                    'id': path,
                    'title': name,
                    'name': name,
                    'thumb': thumb
                }

                oc.add(
                    DirectoryObject(key=Callback(HandleMovieOrSerie,
                                                 **new_params),
                                    title=plex_util.sanitize(name),
                                    thumb=thumb))

            pagination.append_controls(oc,
                                       response,
                                       page=page,
                                       callback=HandleCategoryItems,
                                       title=title,
                                       category_path=category_path)

        return oc
Example #51
0
def HandleCollections(title, page=1):
    oc = ObjectContainer()

    page = int(page)
    limit = util.get_elements_per_page()
    offset = (page - 1) * limit

    response = service.get_collections(limit=limit, offset=offset)

    oc.title2 = unicode(L('Collections')) + ' (' + str(
        response['meta']['total_count']) + ')'

    for media in response['objects']:
        name = media['title']
        thumb = media['thumbnail']

        new_params = {
            'type': 'collection',
            'id': media['id'],
            'collection__id': media['id'],
            'name': name,
            'thumb': thumb
        }
        key = Callback(HandleCollection, **new_params)
        oc.add(DirectoryObject(key=key, title=unicode(name), thumb=thumb))

    oc.add(
        InputDirectoryObject(key=Callback(SearchCollections,
                                          title=unicode(
                                              L("Collections Search"))),
                             title=unicode(L("Collections Search")),
                             thumb=R(SEARCH_ICON)))

    service.add_pagination_to_response(response, page,
                                       util.get_elements_per_page())
    pagination.append_controls(oc,
                               response['data'],
                               callback=HandleCollections,
                               title=title,
                               page=page)

    return oc
Example #52
0
def HandleLatest(page=1):
    oc = ObjectContainer(title1=unicode(L("Latest")))

    response = service.get_latest(page=page)

    for item in response['movies']:
        new_params = {
            # "isSerie": True,
            "name": item['name'],
            "id": item['path'],
            "thumb": item['thumb']
        }
        oc.add(
            DirectoryObject(key=Callback(HandleMovie, **new_params),
                            title=item['name'],
                            thumb=plex_util.get_thumb(item['thumb'])))

    pagination.append_controls(oc, response, callback=HandleLatest, page=page)

    return oc
Example #53
0
def SearchMovies(query=None, page=1, **params):
    response = video_service.search(query=query,
                                    per_page=common.get_elements_per_page(),
                                    page=page)

    oc = ObjectContainer(title2=unicode(L('Movies Search')))

    for media in HandleMediaList(response['data']['media']):
        oc.add(media)

    pagination.append_controls(oc,
                               response,
                               page=page,
                               callback=SearchMovies,
                               query=query)

    if len(oc) < 1:
        return common.no_contents('Movies Search')

    return oc
Example #54
0
def HandleArtists(title, page=1, **params):
    oc = ObjectContainer(title2=unicode(L(title)))

    page = int(page)
    limit = common.get_elements_per_page()
    offset = (page-1)*limit

    response = service.get_artists(limit=limit, offset=offset, **params)

    oc.title2 = unicode(L(title)) + ' (' + str(response['meta']['total_count']) + ')'

    for artist in BuildArtistsList(response['objects']):
        oc.add(artist)

    common.add_pagination_to_response(response, page)
    pagination.append_controls(oc, response, callback=HandleArtists, title=title, page=page)

    add_search_artists(oc)

    return oc
Example #55
0
def HandleSeries(page=1):
    oc = ObjectContainer(title1=unicode(L("Series")))

    response = service.get_series(page=page)

    for item in response['movies']:
        new_params = {
            'type': 'serie',
            'name': item['name'],
            'id': item['path'],
            'thumb': item['thumb']
        }

        oc.add(
            DirectoryObject(key=Callback(HandleSerie, **new_params),
                            title=item['name'],
                            thumb=plex_util.get_thumb(item['thumb'])))

    pagination.append_controls(oc, response, callback=HandleSeries, page=page)

    return oc