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

update some code to support python3 #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 4 additions & 5 deletions ehentai_metadata/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
from __future__ import (unicode_literals, division, absolute_import,
print_function)
Expand All @@ -13,7 +13,7 @@

import re
import json
from urllib import urlencode
from urllib.parse import urlencode

def to_metadata(log,gmetadata,ExHentai_Status): # {{{
title = gmetadata['title']
Expand Down Expand Up @@ -154,8 +154,7 @@ def build_term(type,parts):
if author_token:
q = q + (' ' if q != '' else '') + build_term('author', author_token)
q = q.strip()
if isinstance(q, unicode):
q = q.encode('utf-8')

if not q:
return None
q_dict = {'f_doujinshi':1, 'f_manga':1, 'f_artistcg':1, 'f_gamecg':1, 'f_western':1, 'f_non-h':1,
Expand Down Expand Up @@ -264,7 +263,7 @@ def identify(self, log, result_queue, abort, title=None, authors=None,identifier
br.set_cookie(name=cookie['name'], value=cookie['value'], domain=cookie['domain'], path=cookie['path'])
try:
_raw = br.open_novisit(query,timeout=timeout)
raw = _raw.read()
raw = str(_raw.read())
except Exception as e:
log.exception('Failed to make identify query: %r'%query)
return as_unicode(e)
Expand Down