cenkalti / putio.py

A python wrapper for put.io APIv2
http://put.io
MIT License
72 stars 41 forks source link

File list method does not support all available parameters #49

Closed evoblicec closed 4 years ago

evoblicec commented 4 years ago

Classmethod "List" of Class "File" does not support parameters except 'parent_id'.

Put.io API is providing multiple optional parameters to the List API call for sorting, filtering, etc..

List method could be easily modified to support additional parameters:

 def list(cls, parent_id=0, sort_by='SIZE_DESC', file_type='VIDEO'):
        files = []
        params = {
                'parent_id': parent_id,
                'per_page': '1000',
                'sort_by': sort_by,
                'file_type': file_type,
        }
        d = cls.client.request('/files/list', params=params)
        files.extend(d['files'])
        while d['cursor']:
            data = {'cursor': d['cursor']}
            d = cls.client.request('/files/list/continue', method='POST', data=data)
            files.extend(d['files'])

        return [cls(f) for f in files]
cenkalti commented 4 years ago

@evoblicec Can you send a PR please?

evoblicec commented 4 years ago

PR done

cenkalti commented 4 years ago

@evoblicec Thank you. I have Merged the PR and updated default values. https://github.com/cenkalti/putio.py/commit/3ad41af459dcbdfe2123a4980571611327e02e88

Uploaded the new version to PyPI: https://pypi.org/project/putio.py/