Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] てきとーに機能追加 #4

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

# register
# python setup.py register
# https://pypi.python.org/pypi?%3Aaction=submit_form

python setup.py check -r -s
python setup.py sdist bdist_wheel

twine upload dist/*
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='dmm-search',
version='1.0.1',
version='1.1.0',
description="DMM search API for Python",
py_modules=['dmm'],
package_dir={'': 'src'},
Expand Down
53 changes: 33 additions & 20 deletions src/dmm.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from urllib.parse import urljoin
import requests
import time
import json


class DMM:
def __init__(self, api_id, affiliate_id):
self.baseurl = 'https://api.dmm.com/affiliate/v3'
self.base_url = 'https://api.dmm.com/affiliate/v3/'

# required parameters
self.api_id = api_id
self.api_id = api_id
self.affiliate_id = affiliate_id
self.site = 'DMM.R18'
self.site = 'DMM.R18'

def __get(self, endpoint, params):
url = urljoin(self.base_url, endpoint)
return requests.get(url, params=params).json()

def itemList(self, **params):
params['api_id'] = self.api_id
params['affiliate_id'] = self.affiliate_id

params['site'] = 'DMM.R18'

return self.__get('itemList', params)

def search(self, keyword, hits=10, offset=1, sort='rank'):
url = self.baseurl + '/itemList'
def floorList():
pass

params = {
'api_id': self.api_id,
'affiliate_id': self.affiliate_id,
'site': self.site,
'keyword': keyword,
'hits': hits,
'offset': offset,
'sort': sort
}
def actressSearch():
pass

return requests.get(url, params).json()
def genreSearch():
pass

def makerSearch():
pass

def seriesSearch():
pass

def authorSearch():
pass

if __name__ == '__main__':
import sys
Expand All @@ -35,9 +49,8 @@ def search(self, keyword, hits=10, offset=1, sort='rank'):
query = sys.argv[3]

dmm = DMM(api_id, affiliate_id)
items = dmm.search(query, hits=16, offset=1, sort='date')
items = dmm.itemList(keyword=query, hits=16, offset=1, sort='date')

for item in items['result']['items']:
print(item['title'])
print([genre['name'] for genre in item['iteminfo']['genre']])

1 change: 1 addition & 0 deletions tests/test_dmm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from unittest import TestCase
from nose.tools import ok_, eq_

import dmm

class TestDMM(TestCase):
Expand Down