diff --git a/fanficfare/adapters/__init__.py b/fanficfare/adapters/__init__.py
index 2ef031d7..f4b36bbb 100644
--- a/fanficfare/adapters/__init__.py
+++ b/fanficfare/adapters/__init__.py
@@ -19,6 +19,9 @@ from __future__ import absolute_import
import os, re, sys, glob, types
from os.path import dirname, basename, normpath
import logging
+
+# py2 vs py3 transition
+from ..six import text_type as unicode
from ..six.moves.urllib.parse import urlparse
logger = logging.getLogger(__name__)
@@ -31,154 +34,154 @@ from .. import configurable as configurable
from . import base_efiction_adapter
from . import adapter_test1
from . import adapter_fanfictionnet
-# from . import adapter_fanficcastletvnet
-# from . import adapter_fictionalleyorg
-# from . import adapter_fictionpresscom
-# from . import adapter_ficwadcom
-# from . import adapter_fimfictionnet
-# from . import adapter_mediaminerorg
-# from . import adapter_potionsandsnitches
-# from . import adapter_tenhawkpresentscom
-# from . import adapter_adastrafanficcom
-# from . import adapter_tthfanficorg
-# from . import adapter_twilightednet
-# from . import adapter_whoficcom
-# from . import adapter_siyecouk
-# from . import adapter_archiveofourownorg
-# from . import adapter_ficbooknet
-# from . import adapter_nfacommunitycom
-# from . import adapter_midnightwhispers
-# from . import adapter_ksarchivecom
-# from . import adapter_archiveskyehawkecom
-# from . import adapter_squidgeorgpeja
-# from . import adapter_libraryofmoriacom
-# from . import adapter_wraithbaitcom
-# from . import adapter_dramioneorg
-# from . import adapter_ashwindersycophanthexcom
-# from . import adapter_chaossycophanthexcom
-# from . import adapter_erosnsapphosycophanthexcom
-# from . import adapter_lumossycophanthexcom
-# from . import adapter_occlumencysycophanthexcom
-# from . import adapter_phoenixsongnet
-# from . import adapter_walkingtheplankorg
-# from . import adapter_dokugacom
-# from . import adapter_iketernalnet
-# from . import adapter_storiesofardacom
-# from . import adapter_destinysgatewaycom
-# from . import adapter_ncisfictioncom
-# from . import adapter_fanfiktionde
-# from . import adapter_ponyfictionarchivenet
-# from . import adapter_ncisficcom
-# from . import adapter_nationallibrarynet
-# from . import adapter_themasquenet
-# from . import adapter_pretendercentrecom
-# from . import adapter_darksolaceorg
-# from . import adapter_finestoriescom
-# from . import adapter_hpfanficarchivecom
-# from . import adapter_twilightarchivescom
-# from . import adapter_nhamagicalworldsus
-# from . import adapter_hlfictionnet
-# from . import adapter_dracoandginnycom
-# from . import adapter_scarvesandcoffeenet
-# from . import adapter_thepetulantpoetesscom
-# from . import adapter_wolverineandroguecom
-# from . import adapter_merlinficdtwinscouk
-# from . import adapter_thehookupzonenet
-# from . import adapter_bloodtiesfancom
-# from . import adapter_qafficcom
-# from . import adapter_efpfanficnet
-# from . import adapter_potterficscom
-# from . import adapter_efictionestelielde
-# from . import adapter_imagineeficcom
-# from . import adapter_asr3slashzoneorg
-# from . import adapter_potterheadsanonymouscom
-# from . import adapter_fictionpadcom
-# from . import adapter_storiesonlinenet
-# from . import adapter_trekiverseorg
-# from . import adapter_literotica
-# from . import adapter_voracity2eficcom
-# from . import adapter_spikeluvercom
-# from . import adapter_bloodshedversecom
-# from . import adapter_nocturnallightnet
-# from . import adapter_fanfichu
-# from . import adapter_fictionmaniatv
-# from . import adapter_tolkienfanfiction
-# from . import adapter_themaplebookshelf
-# from . import adapter_fannation
-# from . import adapter_sheppardweircom
-# from . import adapter_samandjacknet
-# from . import adapter_csiforensicscom
-# from . import adapter_lotrfanfictioncom
-# from . import adapter_fhsarchivecom
-# from . import adapter_fanfictionjunkiesde
-# from . import adapter_tgstorytimecom
-# from . import adapter_itcouldhappennet
+from . import adapter_fanficcastletvnet
+from . import adapter_fictionalleyorg
+from . import adapter_fictionpresscom
+from . import adapter_ficwadcom
+from . import adapter_fimfictionnet
+from . import adapter_mediaminerorg
+from . import adapter_potionsandsnitches
+from . import adapter_tenhawkpresentscom
+from . import adapter_adastrafanficcom
+from . import adapter_tthfanficorg
+from . import adapter_twilightednet
+from . import adapter_whoficcom
+from . import adapter_siyecouk
+from . import adapter_archiveofourownorg
+from . import adapter_ficbooknet
+from . import adapter_nfacommunitycom
+from . import adapter_midnightwhispers
+from . import adapter_ksarchivecom
+from . import adapter_archiveskyehawkecom
+from . import adapter_squidgeorgpeja
+from . import adapter_libraryofmoriacom
+from . import adapter_wraithbaitcom
+from . import adapter_dramioneorg
+from . import adapter_ashwindersycophanthexcom
+from . import adapter_chaossycophanthexcom
+from . import adapter_erosnsapphosycophanthexcom
+from . import adapter_lumossycophanthexcom
+from . import adapter_occlumencysycophanthexcom
+from . import adapter_phoenixsongnet
+from . import adapter_walkingtheplankorg
+from . import adapter_dokugacom
+from . import adapter_iketernalnet
+from . import adapter_storiesofardacom
+from . import adapter_destinysgatewaycom
+from . import adapter_ncisfictioncom
+from . import adapter_fanfiktionde
+from . import adapter_ponyfictionarchivenet
+from . import adapter_ncisficcom
+from . import adapter_nationallibrarynet
+from . import adapter_themasquenet
+from . import adapter_pretendercentrecom
+from . import adapter_darksolaceorg
+from . import adapter_finestoriescom
+from . import adapter_hpfanficarchivecom
+from . import adapter_twilightarchivescom
+from . import adapter_nhamagicalworldsus
+from . import adapter_hlfictionnet
+from . import adapter_dracoandginnycom
+from . import adapter_scarvesandcoffeenet
+from . import adapter_thepetulantpoetesscom
+from . import adapter_wolverineandroguecom
+from . import adapter_merlinficdtwinscouk
+from . import adapter_thehookupzonenet
+from . import adapter_bloodtiesfancom
+from . import adapter_qafficcom
+from . import adapter_efpfanficnet
+from . import adapter_potterficscom
+from . import adapter_efictionestelielde
+from . import adapter_imagineeficcom
+from . import adapter_asr3slashzoneorg
+from . import adapter_potterheadsanonymouscom
+from . import adapter_fictionpadcom
+from . import adapter_storiesonlinenet
+from . import adapter_trekiverseorg
+from . import adapter_literotica
+from . import adapter_voracity2eficcom
+from . import adapter_spikeluvercom
+from . import adapter_bloodshedversecom
+from . import adapter_nocturnallightnet
+from . import adapter_fanfichu
+from . import adapter_fictionmaniatv
+from . import adapter_tolkienfanfiction
+from . import adapter_themaplebookshelf
+from . import adapter_fannation
+from . import adapter_sheppardweircom
+from . import adapter_samandjacknet
+from . import adapter_csiforensicscom
+from . import adapter_lotrfanfictioncom
+from . import adapter_fhsarchivecom
+from . import adapter_fanfictionjunkiesde
+from . import adapter_tgstorytimecom
+from . import adapter_itcouldhappennet
from . import adapter_forumsspacebattlescom
-# from . import adapter_forumssufficientvelocitycom
-# from . import adapter_forumquestionablequestingcom
-# from . import adapter_ninelivesarchivecom
-# from . import adapter_masseffect2in
-# from . import adapter_quotevcom
-# from . import adapter_mcstoriescom
-# from . import adapter_buffygilescom
-# from . import adapter_andromedawebcom
-# from . import adapter_artemisfowlcom
-# from . import adapter_naiceanilmenet
-# from . import adapter_deepinmysoulnet
-# from . import adapter_kiarepositorymujajinet
-# from . import adapter_adultfanfictionorg
-# from . import adapter_fictionhuntcom
-# from . import adapter_royalroadl
-# from . import adapter_chosentwofanficcom
-# from . import adapter_bdsmlibrarycom
-# from . import adapter_asexstoriescom
-# from . import adapter_gluttonyfictioncom
-# from . import adapter_valentchambercom
-# from . import adapter_looselugscom
-# from . import adapter_wwwgiantessworldnet
-# from . import adapter_lotrgficcom
-# from . import adapter_tomparisdormcom
-# from . import adapter_writingwhimsicalwanderingsnet
-# from . import adapter_sugarquillnet
-# from . import adapter_wwwarea52hkhnet
-# from . import adapter_starslibrarynet
-# from . import adapter_fanficauthorsnet
-# from . import adapter_fireflyfansnet
-# from . import adapter_fireflypopulliorg
-# from . import adapter_sebklainenet
-# from . import adapter_shriftweborgbfa
-# from . import adapter_trekfanfictionnet
-# from . import adapter_wuxiaworldcom
-# from . import adapter_wwwlushstoriescom
-# from . import adapter_wwwutopiastoriescom
-# from . import adapter_sinfuldreamscomunicornfic
-# from . import adapter_sinfuldreamscomwhisperedmuse
-# from . import adapter_sinfuldreamscomwickedtemptation
-# from . import adapter_asianfanficscom
-# from . import adapter_webnovelcom
-# from . import adapter_deandamagecom
-# from . import adapter_imrightbehindyoucom
-# from . import adapter_mttjustoncenet
-# from . import adapter_narutoficorg
-# from . import adapter_starskyhutcharchivenet
-# from . import adapter_swordborderlineangelcom
-# from . import adapter_tasteofpoisoninkubationnet
-# from . import adapter_thebrokenworldorg
-# from . import adapter_thedelphicexpansecom
-# from . import adapter_thundercatsfansorg
-# from . import adapter_unknowableroomorg
-# from . import adapter_www13hoursorg
-# from . import adapter_wwwaneroticstorycom
-# from . import adapter_gravitytalescom
-# from . import adapter_lcfanficcom
-# from . import adapter_noveltrovecom
-# from . import adapter_inkbunnynet
-# from . import adapter_alternatehistorycom
-# from . import adapter_wattpadcom
-# from . import adapter_lightnovelgatecom
-# from . import adapter_wwwnovelallcom
-# from . import adapter_wuxiaworldco
-# from . import adapter_harrypotterfanfictioncom
+from . import adapter_forumssufficientvelocitycom
+from . import adapter_forumquestionablequestingcom
+from . import adapter_ninelivesarchivecom
+from . import adapter_masseffect2in
+from . import adapter_quotevcom
+from . import adapter_mcstoriescom
+from . import adapter_buffygilescom
+from . import adapter_andromedawebcom
+from . import adapter_artemisfowlcom
+from . import adapter_naiceanilmenet
+from . import adapter_deepinmysoulnet
+from . import adapter_kiarepositorymujajinet
+from . import adapter_adultfanfictionorg
+from . import adapter_fictionhuntcom
+from . import adapter_royalroadl
+from . import adapter_chosentwofanficcom
+from . import adapter_bdsmlibrarycom
+from . import adapter_asexstoriescom
+from . import adapter_gluttonyfictioncom
+from . import adapter_valentchambercom
+from . import adapter_looselugscom
+from . import adapter_wwwgiantessworldnet
+from . import adapter_lotrgficcom
+from . import adapter_tomparisdormcom
+from . import adapter_writingwhimsicalwanderingsnet
+from . import adapter_sugarquillnet
+from . import adapter_wwwarea52hkhnet
+from . import adapter_starslibrarynet
+from . import adapter_fanficauthorsnet
+from . import adapter_fireflyfansnet
+from . import adapter_fireflypopulliorg
+from . import adapter_sebklainenet
+from . import adapter_shriftweborgbfa
+from . import adapter_trekfanfictionnet
+from . import adapter_wuxiaworldcom
+from . import adapter_wwwlushstoriescom
+from . import adapter_wwwutopiastoriescom
+from . import adapter_sinfuldreamscomunicornfic
+from . import adapter_sinfuldreamscomwhisperedmuse
+from . import adapter_sinfuldreamscomwickedtemptation
+from . import adapter_asianfanficscom
+from . import adapter_webnovelcom
+from . import adapter_deandamagecom
+from . import adapter_imrightbehindyoucom
+from . import adapter_mttjustoncenet
+from . import adapter_narutoficorg
+from . import adapter_starskyhutcharchivenet
+from . import adapter_swordborderlineangelcom
+from . import adapter_tasteofpoisoninkubationnet
+from . import adapter_thebrokenworldorg
+from . import adapter_thedelphicexpansecom
+from . import adapter_thundercatsfansorg
+from . import adapter_unknowableroomorg
+from . import adapter_www13hoursorg
+from . import adapter_wwwaneroticstorycom
+from . import adapter_gravitytalescom
+from . import adapter_lcfanficcom
+from . import adapter_noveltrovecom
+from . import adapter_inkbunnynet
+from . import adapter_alternatehistorycom
+from . import adapter_wattpadcom
+from . import adapter_lightnovelgatecom
+from . import adapter_wwwnovelallcom
+from . import adapter_wuxiaworldco
+from . import adapter_harrypotterfanfictioncom
## This bit of complexity allows adapters to be added by just adding
## importing. It eliminates the long if/else clauses we used to need
diff --git a/fanficfare/adapters/adapter_adastrafanficcom.py b/fanficfare/adapters/adapter_adastrafanficcom.py
index f8da90e4..895ad39e 100644
--- a/fanficfare/adapters/adapter_adastrafanficcom.py
+++ b/fanficfare/adapters/adapter_adastrafanficcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,15 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib
-import urllib2
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six import string_types as basestring
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
class AdAstraFanficComSiteAdapter(BaseSiteAdapter):
@@ -73,7 +76,7 @@ class AdAstraFanficComSiteAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_adultfanfictionorg.py b/fanficfare/adapters/adapter_adultfanfictionorg.py
index 2776ffe9..80789adf 100644
--- a/fanficfare/adapters/adapter_adultfanfictionorg.py
+++ b/fanficfare/adapters/adapter_adultfanfictionorg.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# -- coding: utf-8 --
-# Copyright 2013 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2013 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -23,12 +23,15 @@ import logging
logger = logging.getLogger(__name__)
import re
import sys
-import urllib2
from bs4 import UnicodeDammit
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
################################################################################
@@ -199,7 +202,7 @@ class AdultFanFictionOrgAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist("Code: 404. {0}".format(url))
elif e.code == 410:
@@ -265,7 +268,7 @@ class AdultFanFictionOrgAdapter(BaseSiteAdapter):
logger.debug('Getting the author page: {0}'.format(author_Url))
try:
adata = self._fetchUrl(author_Url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code in 404:
raise exceptions.StoryDoesNotExist("Author Page: Code: 404. {0}".format(author_Url))
elif e.code == 410:
@@ -303,7 +306,7 @@ class AdultFanFictionOrgAdapter(BaseSiteAdapter):
logger.debug('Getting the author page: {0}'.format(author_Url))
try:
adata = self._fetchUrl(author_Url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code in 404:
raise exceptions.StoryDoesNotExist("Author Page: Code: 404. {0}".format(author_Url))
elif e.code == 410:
diff --git a/fanficfare/adapters/adapter_alternatehistorycom.py b/fanficfare/adapters/adapter_alternatehistorycom.py
index f7824377..c3d13649 100644
--- a/fanficfare/adapters/adapter_alternatehistorycom.py
+++ b/fanficfare/adapters/adapter_alternatehistorycom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2017 FanFicFare team
+# Copyright 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
#
from __future__ import absolute_import
-from adapter_forumquestionablequestingcom import QuestionablequestingComAdapter
+from .adapter_forumquestionablequestingcom import QuestionablequestingComAdapter
def getClass():
return WWWAlternatehistoryComAdapter
diff --git a/fanficfare/adapters/adapter_andromedawebcom.py b/fanficfare/adapters/adapter_andromedawebcom.py
index 4a35e11e..c0f6e223 100644
--- a/fanficfare/adapters/adapter_andromedawebcom.py
+++ b/fanficfare/adapters/adapter_andromedawebcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2017 FanFicFare team
+# Copyright 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -22,12 +22,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -125,7 +126,7 @@ class AndromedaWebComAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -159,7 +160,7 @@ class AndromedaWebComAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_archiveofourownorg.py b/fanficfare/adapters/adapter_archiveofourownorg.py
index 489a824e..4e8cbfa2 100644
--- a/fanficfare/adapters/adapter_archiveofourownorg.py
+++ b/fanficfare/adapters/adapter_archiveofourownorg.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2014 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2014 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,12 +19,15 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
import json
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -155,7 +158,7 @@ class ArchiveOfOurOwnOrgAdapter(BaseSiteAdapter):
if "This work could have adult content. If you proceed you have agreed that you are willing to see such content." in meta:
raise exceptions.AdultCheckRequired(self.url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_archiveskyehawkecom.py b/fanficfare/adapters/adapter_archiveskyehawkecom.py
index b2307635..459a0416 100644
--- a/fanficfare/adapters/adapter_archiveskyehawkecom.py
+++ b/fanficfare/adapters/adapter_archiveskyehawkecom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,12 +19,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
@@ -80,7 +81,7 @@ class ArchiveSkyeHawkeComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_artemisfowlcom.py b/fanficfare/adapters/adapter_artemisfowlcom.py
index e446cb2e..a6dd1e5a 100644
--- a/fanficfare/adapters/adapter_artemisfowlcom.py
+++ b/fanficfare/adapters/adapter_artemisfowlcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2017 FanFicFare team
+# Copyright 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -22,12 +22,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -125,7 +126,7 @@ class ArtemisFowlComAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -159,7 +160,7 @@ class ArtemisFowlComAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_asexstoriescom.py b/fanficfare/adapters/adapter_asexstoriescom.py
index 3b1d0490..b470c311 100644
--- a/fanficfare/adapters/adapter_asexstoriescom.py
+++ b/fanficfare/adapters/adapter_asexstoriescom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2013 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2013 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,8 +19,6 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-import urlparse
import os
from bs4.element import Comment
@@ -28,6 +26,11 @@ from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
import sys
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib import parse as urlparse
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -83,7 +86,7 @@ class ASexStoriesComAdapter(BaseSiteAdapter):
soup1 = self.make_soup(data1)
#strip comments from soup
[comment.extract() for comment in soup1.find_all(text=lambda text:isinstance(text, Comment))]
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_ashwindersycophanthexcom.py b/fanficfare/adapters/adapter_ashwindersycophanthexcom.py
index 7cb8ff93..699171bf 100644
--- a/fanficfare/adapters/adapter_ashwindersycophanthexcom.py
+++ b/fanficfare/adapters/adapter_ashwindersycophanthexcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -115,7 +116,7 @@ class AshwinderSycophantHexComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_asianfanficscom.py b/fanficfare/adapters/adapter_asianfanficscom.py
index a14818b3..2d65d2df 100644
--- a/fanficfare/adapters/adapter_asianfanficscom.py
+++ b/fanficfare/adapters/adapter_asianfanficscom.py
@@ -4,11 +4,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -125,7 +127,7 @@ class AsianFanFicsComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_asr3slashzoneorg.py b/fanficfare/adapters/adapter_asr3slashzoneorg.py
index 7c678559..91515376 100644
--- a/fanficfare/adapters/adapter_asr3slashzoneorg.py
+++ b/fanficfare/adapters/adapter_asr3slashzoneorg.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2013 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2013 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -85,7 +86,7 @@ class Asr3SlashzoneOrgAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -105,7 +106,7 @@ class Asr3SlashzoneOrgAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_bdsmlibrarycom.py b/fanficfare/adapters/adapter_bdsmlibrarycom.py
index 305c6a51..824c821a 100644
--- a/fanficfare/adapters/adapter_bdsmlibrarycom.py
+++ b/fanficfare/adapters/adapter_bdsmlibrarycom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -51,14 +51,16 @@ import logging
logger = logging.getLogger(__name__)
import re
import urllib
-import urllib2
import sys
-import urlparse
-
from bs4 import Comment
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib import parse as urlparse
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -111,7 +113,7 @@ class BDSMLibraryComSiteAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(self.url)
soup = self.make_soup(data)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -133,7 +135,7 @@ class BDSMLibraryComSiteAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(self.url)
soup = self.make_soup(data)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_bloodshedversecom.py b/fanficfare/adapters/adapter_bloodshedversecom.py
index 4c3cb87a..ace8eca2 100644
--- a/fanficfare/adapters/adapter_bloodshedversecom.py
+++ b/fanficfare/adapters/adapter_bloodshedversecom.py
@@ -1,8 +1,6 @@
from __future__ import absolute_import
from datetime import timedelta
import re
-import urllib2
-import urlparse
import logging
logger = logging.getLogger(__name__)
@@ -10,6 +8,11 @@ logger = logging.getLogger(__name__)
from bs4 import BeautifulSoup
from ..htmlcleanup import stripHTML
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib import parse as urlparse
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
from .. import exceptions
@@ -48,7 +51,7 @@ class BloodshedverseComAdapter(BaseSiteAdapter):
if exception:
try:
data = self._fetchUrl(url, parameters)
- except urllib2.HTTPError:
+ except HTTPError:
raise exception(self.url)
# Just let self._fetchUrl throw the exception, don't catch and
# customize it.
diff --git a/fanficfare/adapters/adapter_bloodtiesfancom.py b/fanficfare/adapters/adapter_bloodtiesfancom.py
index c8f35a42..a6bc2c3c 100644
--- a/fanficfare/adapters/adapter_bloodtiesfancom.py
+++ b/fanficfare/adapters/adapter_bloodtiesfancom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,14 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
from bs4.element import Tag
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
# By virtue of being recent and requiring both is_adult and user/pass,
@@ -150,7 +152,7 @@ class BloodTiesFansComAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -184,7 +186,7 @@ class BloodTiesFansComAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_buffygilescom.py b/fanficfare/adapters/adapter_buffygilescom.py
index f1eb696b..af50231c 100644
--- a/fanficfare/adapters/adapter_buffygilescom.py
+++ b/fanficfare/adapters/adapter_buffygilescom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2017 FanFicFare team
+# Copyright 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -123,7 +124,7 @@ class BuffyGilesComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -157,7 +158,7 @@ class BuffyGilesComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_chaossycophanthexcom.py b/fanficfare/adapters/adapter_chaossycophanthexcom.py
index 448ae1a8..bee50b0f 100644
--- a/fanficfare/adapters/adapter_chaossycophanthexcom.py
+++ b/fanficfare/adapters/adapter_chaossycophanthexcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -88,7 +89,7 @@ class ChaosSycophantHexComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_chosentwofanficcom.py b/fanficfare/adapters/adapter_chosentwofanficcom.py
index f7e0b984..ac9bdd5c 100644
--- a/fanficfare/adapters/adapter_chosentwofanficcom.py
+++ b/fanficfare/adapters/adapter_chosentwofanficcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,13 +20,16 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
import sys
from bs4.element import Comment
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -85,7 +88,7 @@ class ChosenTwoFanFicArchiveAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_csiforensicscom.py b/fanficfare/adapters/adapter_csiforensicscom.py
index 2358ed8b..bab51511 100644
--- a/fanficfare/adapters/adapter_csiforensicscom.py
+++ b/fanficfare/adapters/adapter_csiforensicscom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,12 +19,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
@@ -87,7 +88,7 @@ class CSIForensicsComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_darksolaceorg.py b/fanficfare/adapters/adapter_darksolaceorg.py
index 173b3548..5e49a78c 100644
--- a/fanficfare/adapters/adapter_darksolaceorg.py
+++ b/fanficfare/adapters/adapter_darksolaceorg.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2015 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_deandamagecom.py b/fanficfare/adapters/adapter_deandamagecom.py
index 9f0c1446..a10cfeb3 100644
--- a/fanficfare/adapters/adapter_deandamagecom.py
+++ b/fanficfare/adapters/adapter_deandamagecom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_deepinmysoulnet.py b/fanficfare/adapters/adapter_deepinmysoulnet.py
index b690ae94..678b3ee1 100644
--- a/fanficfare/adapters/adapter_deepinmysoulnet.py
+++ b/fanficfare/adapters/adapter_deepinmysoulnet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2013 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2013 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -123,7 +124,7 @@ class DeepInMySoulNetAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -157,7 +158,7 @@ class DeepInMySoulNetAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_destinysgatewaycom.py b/fanficfare/adapters/adapter_destinysgatewaycom.py
index db5f4cec..5b9c63df 100644
--- a/fanficfare/adapters/adapter_destinysgatewaycom.py
+++ b/fanficfare/adapters/adapter_destinysgatewaycom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -88,7 +89,7 @@ class DestinysGatewayComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -108,7 +109,7 @@ class DestinysGatewayComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_dokugacom.py b/fanficfare/adapters/adapter_dokugacom.py
index dc19fe5c..f98eaa16 100644
--- a/fanficfare/adapters/adapter_dokugacom.py
+++ b/fanficfare/adapters/adapter_dokugacom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,12 +19,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -126,7 +127,7 @@ class DokugaComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_dracoandginnycom.py b/fanficfare/adapters/adapter_dracoandginnycom.py
index 2876faf8..b37cd90c 100644
--- a/fanficfare/adapters/adapter_dracoandginnycom.py
+++ b/fanficfare/adapters/adapter_dracoandginnycom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -122,7 +123,7 @@ class DracoAndGinnyComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -147,7 +148,7 @@ class DracoAndGinnyComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_dramioneorg.py b/fanficfare/adapters/adapter_dramioneorg.py
index c626115f..ce7a0ae4 100644
--- a/fanficfare/adapters/adapter_dramioneorg.py
+++ b/fanficfare/adapters/adapter_dramioneorg.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,14 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
from bs4.element import Tag
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -122,7 +124,7 @@ class DramioneOrgAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_efictionestelielde.py b/fanficfare/adapters/adapter_efictionestelielde.py
index 66a0fce9..81bacbde 100644
--- a/fanficfare/adapters/adapter_efictionestelielde.py
+++ b/fanficfare/adapters/adapter_efictionestelielde.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2013 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2013 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -79,7 +80,7 @@ class EfictionEstelielDeAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_efpfanficnet.py b/fanficfare/adapters/adapter_efpfanficnet.py
index 962f3d7f..a16d01e2 100644
--- a/fanficfare/adapters/adapter_efpfanficnet.py
+++ b/fanficfare/adapters/adapter_efpfanficnet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -110,7 +111,7 @@ class EFPFanFicNet(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_erosnsapphosycophanthexcom.py b/fanficfare/adapters/adapter_erosnsapphosycophanthexcom.py
index cd40a9fb..ad341981 100644
--- a/fanficfare/adapters/adapter_erosnsapphosycophanthexcom.py
+++ b/fanficfare/adapters/adapter_erosnsapphosycophanthexcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -88,7 +89,7 @@ class ErosnSapphoSycophantHexComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -108,7 +109,7 @@ class ErosnSapphoSycophantHexComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_fanficauthorsnet.py b/fanficfare/adapters/adapter_fanficauthorsnet.py
index 1bfe586c..83f2341c 100644
--- a/fanficfare/adapters/adapter_fanficauthorsnet.py
+++ b/fanficfare/adapters/adapter_fanficauthorsnet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# -- coding: utf-8 --
-# Copyright 2013 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2013 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -24,12 +24,15 @@ import logging
logger = logging.getLogger(__name__)
import re
import sys
-import urllib2
from bs4 import UnicodeDammit, Comment
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
####################################################################################################
@@ -157,7 +160,7 @@ class FanficAuthorsNetAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url+'index/', params, usecache=False)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist("Code: 404. {0}".format(url))
elif e.code == 410:
diff --git a/fanficfare/adapters/adapter_fanficcastletvnet.py b/fanficfare/adapters/adapter_fanficcastletvnet.py
index 61d8f0a2..dce86a4a 100644
--- a/fanficfare/adapters/adapter_fanficcastletvnet.py
+++ b/fanficfare/adapters/adapter_fanficcastletvnet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2014 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2014 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
# In general an 'adapter' needs to do these five things:
@@ -138,7 +139,7 @@ class FanficCastleTVNetAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -163,7 +164,7 @@ class FanficCastleTVNetAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_fanfichu.py b/fanficfare/adapters/adapter_fanfichu.py
index 3e59d121..293077a3 100644
--- a/fanficfare/adapters/adapter_fanfichu.py
+++ b/fanficfare/adapters/adapter_fanfichu.py
@@ -1,6 +1,6 @@
# coding=utf-8
-# Copyright 2014 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2014 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -17,8 +17,10 @@
from __future__ import absolute_import
import re
-import urllib2
-import urlparse
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib import parse as urlparse
+from ..six.moves.urllib.error import HTTPError
from .base_adapter import BaseSiteAdapter, makeDate
from .. import exceptions
@@ -62,7 +64,7 @@ class FanficHuAdapter(BaseSiteAdapter):
if exception:
try:
data = self._fetchUrl(url, parameters)
- except urllib2.HTTPError:
+ except HTTPError:
raise exception(self.url)
# Just let self._fetchUrl throw the exception, don't catch and
# customize it.
diff --git a/fanficfare/adapters/adapter_fanfictionjunkiesde.py b/fanficfare/adapters/adapter_fanfictionjunkiesde.py
index 523ab771..d8c95dfc 100644
--- a/fanficfare/adapters/adapter_fanfictionjunkiesde.py
+++ b/fanficfare/adapters/adapter_fanfictionjunkiesde.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
# By virtue of being recent and requiring both is_adult and user/pass,
@@ -147,7 +148,7 @@ class FanfictionJunkiesDeAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_fanfiktionde.py b/fanficfare/adapters/adapter_fanfiktionde.py
index 632185ba..1f47f842 100644
--- a/fanficfare/adapters/adapter_fanfiktionde.py
+++ b/fanficfare/adapters/adapter_fanfiktionde.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -21,13 +21,14 @@ import logging
logger = logging.getLogger(__name__)
import re
import urllib
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -119,7 +120,7 @@ class FanFiktionDeAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_fannation.py b/fanficfare/adapters/adapter_fannation.py
index 6a74ac0f..d34beaf8 100644
--- a/fanficfare/adapters/adapter_fannation.py
+++ b/fanficfare/adapters/adapter_fannation.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2014 Fanficdownloader team, 2015 FanFicFare team
+# Copyright 2014 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_fhsarchivecom.py b/fanficfare/adapters/adapter_fhsarchivecom.py
index a9b0c809..1eed35e8 100644
--- a/fanficfare/adapters/adapter_fhsarchivecom.py
+++ b/fanficfare/adapters/adapter_fhsarchivecom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2014 Fanficdownloader team, 2015 FanFicFare team
+# Copyright 2014 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_ficbooknet.py b/fanficfare/adapters/adapter_ficbooknet.py
index e4000552..afac38e7 100644
--- a/fanficfare/adapters/adapter_ficbooknet.py
+++ b/fanficfare/adapters/adapter_ficbooknet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,13 +20,16 @@ import datetime
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
from .. import translit
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
@@ -77,7 +80,7 @@ class FicBookNetAdapter(BaseSiteAdapter):
logger.debug("URL: "+url)
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_fictionalleyorg.py b/fanficfare/adapters/adapter_fictionalleyorg.py
index ba6f32d4..d7bee1df 100644
--- a/fanficfare/adapters/adapter_fictionalleyorg.py
+++ b/fanficfare/adapters/adapter_fictionalleyorg.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ import logging
logger = logging.getLogger(__name__)
import re
import urllib
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
class FictionAlleyOrgSiteAdapter(BaseSiteAdapter):
@@ -80,7 +81,7 @@ class FictionAlleyOrgSiteAdapter(BaseSiteAdapter):
try:
data = self._postFetchWithIAmOld(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_fictionhuntcom.py b/fanficfare/adapters/adapter_fictionhuntcom.py
index 98dcbe03..de1d203c 100644
--- a/fanficfare/adapters/adapter_fictionhuntcom.py
+++ b/fanficfare/adapters/adapter_fictionhuntcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2016 FanFicFare team
+# Copyright 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,11 +19,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
from .. import exceptions as exceptions
from ..htmlcleanup import stripHTML
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
class FictionHuntComSiteAdapter(BaseSiteAdapter):
@@ -69,7 +71,7 @@ class FictionHuntComSiteAdapter(BaseSiteAdapter):
url = self.url
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.meta)
else:
diff --git a/fanficfare/adapters/adapter_fictionmaniatv.py b/fanficfare/adapters/adapter_fictionmaniatv.py
index a79e7685..b3d64df9 100644
--- a/fanficfare/adapters/adapter_fictionmaniatv.py
+++ b/fanficfare/adapters/adapter_fictionmaniatv.py
@@ -1,7 +1,9 @@
from __future__ import absolute_import
import re
-import urllib2
-import urlparse
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib import parse as urlparse
+from ..six.moves.urllib.error import HTTPError
from .base_adapter import BaseSiteAdapter, makeDate
@@ -45,7 +47,7 @@ class FictionManiaTVAdapter(BaseSiteAdapter):
if exception:
try:
data = self._fetchUrl(url, parameters)
- except urllib2.HTTPError:
+ except HTTPError:
raise exception(self.url)
# Just let self._fetchUrl throw the exception, don't catch and
# customize it.
diff --git a/fanficfare/adapters/adapter_fictionpadcom.py b/fanficfare/adapters/adapter_fictionpadcom.py
index a0066082..9d8dc4e4 100644
--- a/fanficfare/adapters/adapter_fictionpadcom.py
+++ b/fanficfare/adapters/adapter_fictionpadcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2013 Fanficdownloader team, 2015 FanFicFare team
+# Copyright 2013 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,13 +19,16 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
import json
#from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
class FictionPadSiteAdapter(BaseSiteAdapter):
@@ -122,7 +125,7 @@ class FictionPadSiteAdapter(BaseSiteAdapter):
data = data[:data.rindex(";")]
data = data.replace('tables:','"tables":')
tables = json.loads(data)['tables']
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(url)
else:
diff --git a/fanficfare/adapters/adapter_fictionpresscom.py b/fanficfare/adapters/adapter_fictionpresscom.py
index 8d5cef68..132e291f 100644
--- a/fanficfare/adapters/adapter_fictionpresscom.py
+++ b/fanficfare/adapters/adapter_fictionpresscom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2015 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,9 +19,12 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
+
+# py2 vs py3 transition
+from ..six import text_type as unicode
+
## They're from the same people and pretty much identical.
-from adapter_fanfictionnet import FanFictionNetSiteAdapter
+from .adapter_fanfictionnet import FanFictionNetSiteAdapter
class FictionPressComSiteAdapter(FanFictionNetSiteAdapter):
diff --git a/fanficfare/adapters/adapter_ficwadcom.py b/fanficfare/adapters/adapter_ficwadcom.py
index 725584da..aad2d0ea 100644
--- a/fanficfare/adapters/adapter_ficwadcom.py
+++ b/fanficfare/adapters/adapter_ficwadcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2015 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,12 +19,14 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-import httplib, urllib
from .. import exceptions as exceptions
from ..htmlcleanup import stripHTML
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
class FicwadComSiteAdapter(BaseSiteAdapter):
@@ -95,7 +97,7 @@ class FicwadComSiteAdapter(BaseSiteAdapter):
if "
Featured Story
" in data:
raise exceptions.StoryDoesNotExist(self.url)
soup = self.make_soup(data)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -117,7 +119,7 @@ class FicwadComSiteAdapter(BaseSiteAdapter):
self._setURL(url)
try:
soup = self.make_soup(self._fetchUrl(url))
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_fimfictionnet.py b/fanficfare/adapters/adapter_fimfictionnet.py
index 88c4000a..444e6b68 100644
--- a/fanficfare/adapters/adapter_fimfictionnet.py
+++ b/fanficfare/adapters/adapter_fimfictionnet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -21,13 +21,16 @@ from datetime import date, datetime
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-import cookielib as cl
import json
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+from ..six.moves import http_cookiejar as cl
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -98,7 +101,7 @@ class FimFictionNetSiteAdapter(BaseSiteAdapter):
data = self.do_fix_blockquotes(self._fetchUrl(self.url,
usecache=(not self.is_adult)))
soup = self.make_soup(data)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_finestoriescom.py b/fanficfare/adapters/adapter_finestoriescom.py
index 2c66b756..81be7f5a 100644
--- a/fanficfare/adapters/adapter_finestoriescom.py
+++ b/fanficfare/adapters/adapter_finestoriescom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2013 Fanficdownloader team, 2015 FanFicFare team
+# Copyright 2013 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,7 +18,11 @@
from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
-from adapter_storiesonlinenet import StoriesOnlineNetAdapter
+
+# py2 vs py3 transition
+from ..six import text_type as unicode
+
+from .adapter_storiesonlinenet import StoriesOnlineNetAdapter
def getClass():
return FineStoriesComAdapter
diff --git a/fanficfare/adapters/adapter_fireflyfansnet.py b/fanficfare/adapters/adapter_fireflyfansnet.py
index 27ae6b44..989e5b4b 100644
--- a/fanficfare/adapters/adapter_fireflyfansnet.py
+++ b/fanficfare/adapters/adapter_fireflyfansnet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -22,7 +22,9 @@ from __future__ import absolute_import
import logging
import re
import sys
-import urllib2
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
from .base_adapter import BaseSiteAdapter, makeDate
@@ -79,7 +81,7 @@ class FireFlyFansNetSiteAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_fireflypopulliorg.py b/fanficfare/adapters/adapter_fireflypopulliorg.py
index 48b45cc8..50f6cf40 100644
--- a/fanficfare/adapters/adapter_fireflypopulliorg.py
+++ b/fanficfare/adapters/adapter_fireflypopulliorg.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Copyright 2017 FanFicFare team
+# Copyright 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -25,9 +25,12 @@ from __future__ import absolute_import
''' This adapter scrapes the metadata and chapter text from stories on firefly.populli.org '''
import logging
import re
-import urllib2
import sys
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
from .. import exceptions as exceptions
@@ -98,7 +101,7 @@ class FireflyPopulliOrgSiteAdapter(BaseSiteAdapter):
'''
try:
page_data = self._fetchUrl(page)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist('404 error: {}'.format(page))
else:
diff --git a/fanficfare/adapters/adapter_forumquestionablequestingcom.py b/fanficfare/adapters/adapter_forumquestionablequestingcom.py
index d67b2627..59c6d534 100644
--- a/fanficfare/adapters/adapter_forumquestionablequestingcom.py
+++ b/fanficfare/adapters/adapter_forumquestionablequestingcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2017 FanFicFare team
+# Copyright 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_gluttonyfictioncom.py b/fanficfare/adapters/adapter_gluttonyfictioncom.py
index b9ee9207..adfc6439 100644
--- a/fanficfare/adapters/adapter_gluttonyfictioncom.py
+++ b/fanficfare/adapters/adapter_gluttonyfictioncom.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
-# Copyright 2015 FanFicFare team
-# Copyright 2016 FanFicFare team
+# Copyright 2018 FanFicFare team
+# Copyright 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_gravitytalescom.py b/fanficfare/adapters/adapter_gravitytalescom.py
index c2551217..7ca0b57a 100644
--- a/fanficfare/adapters/adapter_gravitytalescom.py
+++ b/fanficfare/adapters/adapter_gravitytalescom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2014 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2014 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@
from __future__ import absolute_import
import logging
import re
-import urllib2
from datetime import datetime
logger = logging.getLogger(__name__)
@@ -37,6 +36,10 @@ except ImportError:
# logger.warn('No version of feedparser module available, falling back to naive published and updated date')
feedparser = None
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter
from .. import exceptions as exceptions
@@ -93,7 +96,7 @@ class GravityTalesComSiteAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist('Error 404: {0}'.format(self.url))
else:
diff --git a/fanficfare/adapters/adapter_harrypotterfanfictioncom.py b/fanficfare/adapters/adapter_harrypotterfanfictioncom.py
index d95133a1..8a709e38 100644
--- a/fanficfare/adapters/adapter_harrypotterfanfictioncom.py
+++ b/fanficfare/adapters/adapter_harrypotterfanfictioncom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,12 +19,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
class HarryPotterFanFictionComSiteAdapter(BaseSiteAdapter):
@@ -70,7 +71,7 @@ class HarryPotterFanFictionComSiteAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_hlfictionnet.py b/fanficfare/adapters/adapter_hlfictionnet.py
index c1bc6338..0292fb8a 100644
--- a/fanficfare/adapters/adapter_hlfictionnet.py
+++ b/fanficfare/adapters/adapter_hlfictionnet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -78,7 +79,7 @@ class HLFictionNetAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_hpfanficarchivecom.py b/fanficfare/adapters/adapter_hpfanficarchivecom.py
index 7820405e..e0e597e2 100644
--- a/fanficfare/adapters/adapter_hpfanficarchivecom.py
+++ b/fanficfare/adapters/adapter_hpfanficarchivecom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,14 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
from bs4.element import Comment
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -78,7 +80,7 @@ class HPFanficArchiveComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_iketernalnet.py b/fanficfare/adapters/adapter_iketernalnet.py
index 7a2027c1..68000aeb 100644
--- a/fanficfare/adapters/adapter_iketernalnet.py
+++ b/fanficfare/adapters/adapter_iketernalnet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,11 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -121,7 +123,7 @@ class IkEternalNetAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -159,7 +161,7 @@ class IkEternalNetAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_imagineeficcom.py b/fanficfare/adapters/adapter_imagineeficcom.py
index e1ba1be2..c80b895d 100644
--- a/fanficfare/adapters/adapter_imagineeficcom.py
+++ b/fanficfare/adapters/adapter_imagineeficcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2013 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2013 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -122,7 +123,7 @@ class ImagineEFicComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -147,7 +148,7 @@ class ImagineEFicComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_imrightbehindyoucom.py b/fanficfare/adapters/adapter_imrightbehindyoucom.py
index 48fbd3bc..ba1c47db 100644
--- a/fanficfare/adapters/adapter_imrightbehindyoucom.py
+++ b/fanficfare/adapters/adapter_imrightbehindyoucom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_inkbunnynet.py b/fanficfare/adapters/adapter_inkbunnynet.py
index 6c4d718f..1b6c2c5b 100644
--- a/fanficfare/adapters/adapter_inkbunnynet.py
+++ b/fanficfare/adapters/adapter_inkbunnynet.py
@@ -22,14 +22,17 @@ from __future__ import absolute_import
import logging
import re
import sys
-import urllib2
from datetime import datetime, timedelta
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
from .. import exceptions as exceptions
from ..htmlcleanup import stripHTML
-UNIX_EPOCHE = datetime.fromtimestamp(0)
+UNIX_EPOCHE = datetime.fromtimestamp(86400)
logger = logging.getLogger(__name__)
@@ -123,7 +126,7 @@ class InkBunnyNetSiteAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist('Error 404: {0}'.format(self.url))
else:
diff --git a/fanficfare/adapters/adapter_itcouldhappennet.py b/fanficfare/adapters/adapter_itcouldhappennet.py
index 75d6171a..1bd03f15 100644
--- a/fanficfare/adapters/adapter_itcouldhappennet.py
+++ b/fanficfare/adapters/adapter_itcouldhappennet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2015 FanFicFare team
+# Copyright 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_kiarepositorymujajinet.py b/fanficfare/adapters/adapter_kiarepositorymujajinet.py
index ec4bfbd1..8a8ba785 100644
--- a/fanficfare/adapters/adapter_kiarepositorymujajinet.py
+++ b/fanficfare/adapters/adapter_kiarepositorymujajinet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2013 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2013 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -123,7 +124,7 @@ class KiaRepositoryMujajiNetAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -157,7 +158,7 @@ class KiaRepositoryMujajiNetAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_ksarchivecom.py b/fanficfare/adapters/adapter_ksarchivecom.py
index 9837e9c6..299fa9f7 100644
--- a/fanficfare/adapters/adapter_ksarchivecom.py
+++ b/fanficfare/adapters/adapter_ksarchivecom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
# Search for XXX comments--that's where things are most likely to need changing.
@@ -101,7 +102,7 @@ class KSArchiveComAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -134,7 +135,7 @@ class KSArchiveComAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_lcfanficcom.py b/fanficfare/adapters/adapter_lcfanficcom.py
index d0088687..6faadd8b 100644
--- a/fanficfare/adapters/adapter_lcfanficcom.py
+++ b/fanficfare/adapters/adapter_lcfanficcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2014 Fanficdownloader team, 2015 FanFicFare team
+# Copyright 2014 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -23,9 +23,12 @@ import logging
import json
import re
import sys # ## used for debug purposes
-import urllib2
import datetime
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
from .. import exceptions as exceptions
@@ -96,7 +99,7 @@ class LCFanFicComSiteAdapter(BaseSiteAdapter):
url = self.url
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist('Error 404: {0}'.format(self.url))
else:
diff --git a/fanficfare/adapters/adapter_libraryofmoriacom.py b/fanficfare/adapters/adapter_libraryofmoriacom.py
index 88d7a847..adefe3b5 100644
--- a/fanficfare/adapters/adapter_libraryofmoriacom.py
+++ b/fanficfare/adapters/adapter_libraryofmoriacom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2015 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_lightnovelgatecom.py b/fanficfare/adapters/adapter_lightnovelgatecom.py
index e33d5f74..9c2fe519 100644
--- a/fanficfare/adapters/adapter_lightnovelgatecom.py
+++ b/fanficfare/adapters/adapter_lightnovelgatecom.py
@@ -22,8 +22,10 @@
from __future__ import absolute_import
import logging
import re
-import urllib2
-import urlparse
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib import parse as urlparse
+from ..six.moves.urllib.error import HTTPError
from .base_adapter import BaseSiteAdapter, makeDate
@@ -96,7 +98,7 @@ class LightNovelGateSiteAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist('404 error: {}'.format(url))
else:
diff --git a/fanficfare/adapters/adapter_literotica.py b/fanficfare/adapters/adapter_literotica.py
index 0f9b9dd1..0422ae75 100644
--- a/fanficfare/adapters/adapter_literotica.py
+++ b/fanficfare/adapters/adapter_literotica.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2013 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2013 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,13 +19,16 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-import urlparse
from bs4.element import Comment
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib import parse as urlparse
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
class LiteroticaSiteAdapter(BaseSiteAdapter):
@@ -132,7 +135,7 @@ class LiteroticaSiteAdapter(BaseSiteAdapter):
soup1 = self.make_soup(data1)
#strip comments from soup
[comment.extract() for comment in soup1.findAll(text=lambda text:isinstance(text, Comment))]
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code in [404, 410]:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -157,7 +160,7 @@ class LiteroticaSiteAdapter(BaseSiteAdapter):
#strip comments from soup
[comment.extract() for comment in soupAuth.findAll(text=lambda text:isinstance(text, Comment))]
# logger.debug(soupAuth)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code in [404, 410]:
raise exceptions.StoryDoesNotExist(authorurl)
else:
diff --git a/fanficfare/adapters/adapter_looselugscom.py b/fanficfare/adapters/adapter_looselugscom.py
index 72ef3709..9d72db0c 100644
--- a/fanficfare/adapters/adapter_looselugscom.py
+++ b/fanficfare/adapters/adapter_looselugscom.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
-# Copyright 2015 FanFicFare team
-# Copyright 2016 FanFicFare team
+# Copyright 2018 FanFicFare team
+# Copyright 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_lotrfanfictioncom.py b/fanficfare/adapters/adapter_lotrfanfictioncom.py
index 6be94d75..a57e7d83 100644
--- a/fanficfare/adapters/adapter_lotrfanfictioncom.py
+++ b/fanficfare/adapters/adapter_lotrfanfictioncom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2014 Fanficdownloader team, 2015 FanFicFare team
+# Copyright 2014 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_lotrgficcom.py b/fanficfare/adapters/adapter_lotrgficcom.py
index 362824bb..ffda5d6b 100644
--- a/fanficfare/adapters/adapter_lotrgficcom.py
+++ b/fanficfare/adapters/adapter_lotrgficcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -23,11 +23,13 @@ import logging
logger = logging.getLogger(__name__)
import re
import urllib
-import urllib2
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
class LOTRgficComAdapter(BaseSiteAdapter):
@@ -79,7 +81,7 @@ class LOTRgficComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_lumossycophanthexcom.py b/fanficfare/adapters/adapter_lumossycophanthexcom.py
index f8c59acc..6b8f1c84 100644
--- a/fanficfare/adapters/adapter_lumossycophanthexcom.py
+++ b/fanficfare/adapters/adapter_lumossycophanthexcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -88,7 +89,7 @@ class LumosSycophantHexComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_masseffect2in.py b/fanficfare/adapters/adapter_masseffect2in.py
index 1facf33e..3de5f4e7 100644
--- a/fanficfare/adapters/adapter_masseffect2in.py
+++ b/fanficfare/adapters/adapter_masseffect2in.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2017 FanFicFare team
+# Copyright 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,10 +20,12 @@ import bs4
import datetime
import logging
import re
-import urllib2
-
from ..htmlcleanup import removeEntities, stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
@@ -115,7 +117,7 @@ class MassEffect2InAdapter(BaseSiteAdapter):
try:
startingChapter = self._makeChapter(self.url)
- except urllib2.HTTPError, error:
+ except HTTPError as error:
if error.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
raise
@@ -199,7 +201,7 @@ class MassEffect2InAdapter(BaseSiteAdapter):
chapterTitle = re.sub(garbagePattern, u'', chapter.getHeading()[chapterTitleStart:])
self.add_chapter(chapterTitle, url)
- except ParsingError, error:
+ except ParsingError as error:
raise exceptions.FailedToDownload(u"Failed to download chapter `%s': %s" % (url, error))
# Some metadata are handled separately due to format conversions.
diff --git a/fanficfare/adapters/adapter_mcstoriescom.py b/fanficfare/adapters/adapter_mcstoriescom.py
index 289758cc..954d15bb 100644
--- a/fanficfare/adapters/adapter_mcstoriescom.py
+++ b/fanficfare/adapters/adapter_mcstoriescom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2013 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2013 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,14 +19,17 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-import urlparse
import os
from bs4.element import Comment
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib import parse as urlparse
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
class MCStoriesComSiteAdapter(BaseSiteAdapter):
@@ -85,7 +88,7 @@ class MCStoriesComSiteAdapter(BaseSiteAdapter):
soup1 = self.make_soup(data1)
#strip comments from soup
[comment.extract() for comment in soup1.find_all(text=lambda text:isinstance(text, Comment))]
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_mediaminerorg.py b/fanficfare/adapters/adapter_mediaminerorg.py
index eeee32c4..c23c1326 100644
--- a/fanficfare/adapters/adapter_mediaminerorg.py
+++ b/fanficfare/adapters/adapter_mediaminerorg.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,11 +20,13 @@ import logging
logger = logging.getLogger(__name__)
import re
import urllib
-import urllib2
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
class MediaMinerOrgSiteAdapter(BaseSiteAdapter):
@@ -108,7 +110,7 @@ class MediaMinerOrgSiteAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url) # w/o trailing / gets 'chapter list' page even for one-shots.
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
logger.error("404 on %s"%url)
raise exceptions.StoryDoesNotExist(self.url)
diff --git a/fanficfare/adapters/adapter_merlinficdtwinscouk.py b/fanficfare/adapters/adapter_merlinficdtwinscouk.py
index 7345eeae..2385ae0a 100644
--- a/fanficfare/adapters/adapter_merlinficdtwinscouk.py
+++ b/fanficfare/adapters/adapter_merlinficdtwinscouk.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -122,7 +123,7 @@ class MerlinFicDtwinsCoUk(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -147,7 +148,7 @@ class MerlinFicDtwinsCoUk(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_midnightwhispers.py b/fanficfare/adapters/adapter_midnightwhispers.py
index 7f818744..7c885752 100644
--- a/fanficfare/adapters/adapter_midnightwhispers.py
+++ b/fanficfare/adapters/adapter_midnightwhispers.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
# Search for XXX comments--that's where things are most likely to need changing.
@@ -106,7 +107,7 @@ class MidnightwhispersAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -139,7 +140,7 @@ class MidnightwhispersAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_mttjustoncenet.py b/fanficfare/adapters/adapter_mttjustoncenet.py
index ace5dd19..5349b40b 100644
--- a/fanficfare/adapters/adapter_mttjustoncenet.py
+++ b/fanficfare/adapters/adapter_mttjustoncenet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_naiceanilmenet.py b/fanficfare/adapters/adapter_naiceanilmenet.py
index d6ccc27e..758ef07f 100644
--- a/fanficfare/adapters/adapter_naiceanilmenet.py
+++ b/fanficfare/adapters/adapter_naiceanilmenet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2016 FanFicFare team
+# Copyright 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_narutoficorg.py b/fanficfare/adapters/adapter_narutoficorg.py
index e65a7666..2d0bbd92 100644
--- a/fanficfare/adapters/adapter_narutoficorg.py
+++ b/fanficfare/adapters/adapter_narutoficorg.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_nationallibrarynet.py b/fanficfare/adapters/adapter_nationallibrarynet.py
index 61c77349..b569b0c2 100644
--- a/fanficfare/adapters/adapter_nationallibrarynet.py
+++ b/fanficfare/adapters/adapter_nationallibrarynet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -83,7 +84,7 @@ class NationalLibraryNetAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_ncisficcom.py b/fanficfare/adapters/adapter_ncisficcom.py
index 7f378448..bcab3f51 100644
--- a/fanficfare/adapters/adapter_ncisficcom.py
+++ b/fanficfare/adapters/adapter_ncisficcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -82,7 +83,7 @@ class NCISFicComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_ncisfictioncom.py b/fanficfare/adapters/adapter_ncisfictioncom.py
index 03746e5b..aa90d1c3 100644
--- a/fanficfare/adapters/adapter_ncisfictioncom.py
+++ b/fanficfare/adapters/adapter_ncisfictioncom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_nfacommunitycom.py b/fanficfare/adapters/adapter_nfacommunitycom.py
index f860c6a0..e7da293b 100644
--- a/fanficfare/adapters/adapter_nfacommunitycom.py
+++ b/fanficfare/adapters/adapter_nfacommunitycom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
# Search for XXX comments--that's where things are most likely to need changing.
@@ -101,7 +102,7 @@ class NfaCommunityComAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -134,7 +135,7 @@ class NfaCommunityComAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_nhamagicalworldsus.py b/fanficfare/adapters/adapter_nhamagicalworldsus.py
index 9b74d3e1..6328e04c 100644
--- a/fanficfare/adapters/adapter_nhamagicalworldsus.py
+++ b/fanficfare/adapters/adapter_nhamagicalworldsus.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2015 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_ninelivesarchivecom.py b/fanficfare/adapters/adapter_ninelivesarchivecom.py
index e0d6eacc..72907fe8 100644
--- a/fanficfare/adapters/adapter_ninelivesarchivecom.py
+++ b/fanficfare/adapters/adapter_ninelivesarchivecom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2015 Fanficdownloader team, 2015 FanFicFare team
+# Copyright 2015 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_nocturnallightnet.py b/fanficfare/adapters/adapter_nocturnallightnet.py
index 65612154..a0a63161 100644
--- a/fanficfare/adapters/adapter_nocturnallightnet.py
+++ b/fanficfare/adapters/adapter_nocturnallightnet.py
@@ -2,11 +2,13 @@
from __future__ import absolute_import
import re
-import urllib2
-import urlparse
-
from bs4.element import Tag
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib import parse as urlparse
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
from .. import exceptions
@@ -48,7 +50,7 @@ class NocturnalLightNetAdapter(BaseSiteAdapter):
if exception:
try:
data = self._fetchUrl(url, parameters)
- except urllib2.HTTPError:
+ except HTTPError:
raise exception(self.url)
# Just let self._fetchUrl throw the exception, don't catch and
# customize it.
diff --git a/fanficfare/adapters/adapter_noveltrovecom.py b/fanficfare/adapters/adapter_noveltrovecom.py
index 5948674e..0dd88c38 100644
--- a/fanficfare/adapters/adapter_noveltrovecom.py
+++ b/fanficfare/adapters/adapter_noveltrovecom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2014 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2014 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -23,9 +23,12 @@ import logging
import json
import re
import sys # ## used for debug purposes
-import urllib2
import datetime
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
from .. import exceptions as exceptions
@@ -88,7 +91,7 @@ class NovelTroveComSiteAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist('Error 404: {0}'.format(self.url))
else:
diff --git a/fanficfare/adapters/adapter_occlumencysycophanthexcom.py b/fanficfare/adapters/adapter_occlumencysycophanthexcom.py
index 7e321405..14ff543e 100644
--- a/fanficfare/adapters/adapter_occlumencysycophanthexcom.py
+++ b/fanficfare/adapters/adapter_occlumencysycophanthexcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -114,7 +115,7 @@ class OcclumencySycophantHexComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_phoenixsongnet.py b/fanficfare/adapters/adapter_phoenixsongnet.py
index d84c1146..22c37153 100644
--- a/fanficfare/adapters/adapter_phoenixsongnet.py
+++ b/fanficfare/adapters/adapter_phoenixsongnet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,12 +19,14 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2, urllib, cookielib
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -111,7 +113,7 @@ class PhoenixSongNetAdapter(BaseSiteAdapter):
if self.getConfig('force_login'):
self.performLogin(url)
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_ponyfictionarchivenet.py b/fanficfare/adapters/adapter_ponyfictionarchivenet.py
index 8a6d5028..f3be33f6 100644
--- a/fanficfare/adapters/adapter_ponyfictionarchivenet.py
+++ b/fanficfare/adapters/adapter_ponyfictionarchivenet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -92,7 +93,7 @@ class PonyFictionArchiveNetAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -113,7 +114,7 @@ class PonyFictionArchiveNetAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_potionsandsnitches.py b/fanficfare/adapters/adapter_potionsandsnitches.py
index 142b2bdf..49fa91f3 100644
--- a/fanficfare/adapters/adapter_potionsandsnitches.py
+++ b/fanficfare/adapters/adapter_potionsandsnitches.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -21,12 +21,13 @@ import logging
logger = logging.getLogger(__name__)
import re
import urllib
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
class PotionsAndSnitchesOrgSiteAdapter(BaseSiteAdapter):
@@ -65,7 +66,7 @@ class PotionsAndSnitchesOrgSiteAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_potterficscom.py b/fanficfare/adapters/adapter_potterficscom.py
index c7323227..582e3c83 100644
--- a/fanficfare/adapters/adapter_potterficscom.py
+++ b/fanficfare/adapters/adapter_potterficscom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2013 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2013 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ import datetime
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter
# This function is called by the downloader in all adapter_*.py files
@@ -145,7 +146,7 @@ class PotterFicsComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_potterheadsanonymouscom.py b/fanficfare/adapters/adapter_potterheadsanonymouscom.py
index 5aad67b5..97f53150 100644
--- a/fanficfare/adapters/adapter_potterheadsanonymouscom.py
+++ b/fanficfare/adapters/adapter_potterheadsanonymouscom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2013 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2013 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -122,7 +123,7 @@ class PotterHeadsAnonymousComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -156,7 +157,7 @@ class PotterHeadsAnonymousComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_pretendercentrecom.py b/fanficfare/adapters/adapter_pretendercentrecom.py
index c6bc603d..789a0184 100644
--- a/fanficfare/adapters/adapter_pretendercentrecom.py
+++ b/fanficfare/adapters/adapter_pretendercentrecom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -91,7 +92,7 @@ class PretenderCenterComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -111,7 +112,7 @@ class PretenderCenterComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_qafficcom.py b/fanficfare/adapters/adapter_qafficcom.py
index 4bea9eeb..7fa6df5f 100644
--- a/fanficfare/adapters/adapter_qafficcom.py
+++ b/fanficfare/adapters/adapter_qafficcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -88,7 +89,7 @@ class QafFicComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -108,7 +109,7 @@ class QafFicComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_quotevcom.py b/fanficfare/adapters/adapter_quotevcom.py
index 588a5ea5..84ddfdc2 100644
--- a/fanficfare/adapters/adapter_quotevcom.py
+++ b/fanficfare/adapters/adapter_quotevcom.py
@@ -2,11 +2,14 @@
from __future__ import absolute_import
import re
-import urlparse
-import urllib2
import datetime
from .. import exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib import parse as urlparse
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter
from ..htmlcleanup import stripHTML
@@ -52,7 +55,7 @@ class QuotevComAdapter(BaseSiteAdapter):
def extractChapterUrlsAndMetadata(self):
try:
data = self._fetchUrl(self.url)
- except urllib2.HTTPError as e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist("Code: %s: %s"%(e.code,self.url))
else:
diff --git a/fanficfare/adapters/adapter_royalroadl.py b/fanficfare/adapters/adapter_royalroadl.py
index 44b6cfd9..959f6419 100644
--- a/fanficfare/adapters/adapter_royalroadl.py
+++ b/fanficfare/adapters/adapter_royalroadl.py
@@ -18,14 +18,17 @@
from __future__ import absolute_import
import contextlib
from datetime import datetime
-import httplib
import logging
import re
-import urllib2
-
from .. import exceptions as exceptions
from ..dateutils import parse_relative_date_string
from ..htmlcleanup import stripHTML
+
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves import http_client as httplib
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter
logger = logging.getLogger(__name__)
@@ -143,7 +146,7 @@ class RoyalRoadAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_samandjacknet.py b/fanficfare/adapters/adapter_samandjacknet.py
index 372a7a29..7a6395f6 100644
--- a/fanficfare/adapters/adapter_samandjacknet.py
+++ b/fanficfare/adapters/adapter_samandjacknet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,12 +19,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
# By virtue of being recent and requiring both is_adult and user/pass,
@@ -151,7 +152,7 @@ class SamAndJackNetAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -184,7 +185,7 @@ class SamAndJackNetAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_scarvesandcoffeenet.py b/fanficfare/adapters/adapter_scarvesandcoffeenet.py
index 0b195f4c..79677349 100644
--- a/fanficfare/adapters/adapter_scarvesandcoffeenet.py
+++ b/fanficfare/adapters/adapter_scarvesandcoffeenet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -96,7 +97,7 @@ class ScarvesAndCoffeeNetAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -116,7 +117,7 @@ class ScarvesAndCoffeeNetAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_sebklainenet.py b/fanficfare/adapters/adapter_sebklainenet.py
index 05d05ae8..116d5f70 100644
--- a/fanficfare/adapters/adapter_sebklainenet.py
+++ b/fanficfare/adapters/adapter_sebklainenet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2015 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_sheppardweircom.py b/fanficfare/adapters/adapter_sheppardweircom.py
index f8eee2c9..1a959410 100644
--- a/fanficfare/adapters/adapter_sheppardweircom.py
+++ b/fanficfare/adapters/adapter_sheppardweircom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,12 +19,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
# By virtue of being recent and requiring both is_adult and user/pass,
@@ -146,7 +147,7 @@ class SheppardWeirComAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_shriftweborgbfa.py b/fanficfare/adapters/adapter_shriftweborgbfa.py
index d6fdbe77..261fcd7e 100644
--- a/fanficfare/adapters/adapter_shriftweborgbfa.py
+++ b/fanficfare/adapters/adapter_shriftweborgbfa.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Copyright 2017 FanFicFare team
+# Copyright 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -25,9 +25,12 @@ from __future__ import absolute_import
''' This adapter scrapes the metadata and chapter text from stories on archive.shriftweb.org '''
import logging
import re
-import urllib2
import sys
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
from .. import exceptions as exceptions
@@ -98,7 +101,7 @@ class BFAArchiveShriftwebOrgSiteAdapter(BaseSiteAdapter):
'''
try:
page_data = self._fetchUrl(page)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist('404 error: {}'.format(page))
else:
diff --git a/fanficfare/adapters/adapter_sinfuldreamscomunicornfic.py b/fanficfare/adapters/adapter_sinfuldreamscomunicornfic.py
index f69d31e8..e2c56509 100644
--- a/fanficfare/adapters/adapter_sinfuldreamscomunicornfic.py
+++ b/fanficfare/adapters/adapter_sinfuldreamscomunicornfic.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_sinfuldreamscomwhisperedmuse.py b/fanficfare/adapters/adapter_sinfuldreamscomwhisperedmuse.py
index c8d868eb..595c4c66 100644
--- a/fanficfare/adapters/adapter_sinfuldreamscomwhisperedmuse.py
+++ b/fanficfare/adapters/adapter_sinfuldreamscomwhisperedmuse.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_sinfuldreamscomwickedtemptation.py b/fanficfare/adapters/adapter_sinfuldreamscomwickedtemptation.py
index 38ea9e04..44cc733f 100644
--- a/fanficfare/adapters/adapter_sinfuldreamscomwickedtemptation.py
+++ b/fanficfare/adapters/adapter_sinfuldreamscomwickedtemptation.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_siyecouk.py b/fanficfare/adapters/adapter_siyecouk.py
index 34914c05..e08524a6 100644
--- a/fanficfare/adapters/adapter_siyecouk.py
+++ b/fanficfare/adapters/adapter_siyecouk.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
# This function is called by the downloader in all adapter_*.py files
@@ -83,7 +84,7 @@ class SiyeCoUkAdapter(BaseSiteAdapter): # XXX
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_spikeluvercom.py b/fanficfare/adapters/adapter_spikeluvercom.py
index 6150644f..3d1493fb 100644
--- a/fanficfare/adapters/adapter_spikeluvercom.py
+++ b/fanficfare/adapters/adapter_spikeluvercom.py
@@ -1,12 +1,15 @@
# Software: eFiction
from __future__ import absolute_import
import re
-import urllib2
-import urlparse
from bs4.element import Tag
from ..htmlcleanup import stripHTML
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib import parse as urlparse
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
from .. import exceptions
@@ -52,7 +55,7 @@ class SpikeluverComAdapter(BaseSiteAdapter):
if exception:
try:
data = self._fetchUrl(url, parameters)
- except urllib2.HTTPError:
+ except HTTPError:
raise exception(self.url)
# Just let self._fetchUrl throw the exception, don't catch and
# customize it.
diff --git a/fanficfare/adapters/adapter_squidgeorgpeja.py b/fanficfare/adapters/adapter_squidgeorgpeja.py
index 8e703f2f..105866ed 100644
--- a/fanficfare/adapters/adapter_squidgeorgpeja.py
+++ b/fanficfare/adapters/adapter_squidgeorgpeja.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
@@ -93,7 +94,7 @@ class SquidgeOrgPejaAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_starskyhutcharchivenet.py b/fanficfare/adapters/adapter_starskyhutcharchivenet.py
index 331978a4..9c4df433 100644
--- a/fanficfare/adapters/adapter_starskyhutcharchivenet.py
+++ b/fanficfare/adapters/adapter_starskyhutcharchivenet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_starslibrarynet.py b/fanficfare/adapters/adapter_starslibrarynet.py
index fa060ae0..a5557eba 100644
--- a/fanficfare/adapters/adapter_starslibrarynet.py
+++ b/fanficfare/adapters/adapter_starslibrarynet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_storiesofardacom.py b/fanficfare/adapters/adapter_storiesofardacom.py
index 8154191b..0a0de89b 100644
--- a/fanficfare/adapters/adapter_storiesofardacom.py
+++ b/fanficfare/adapters/adapter_storiesofardacom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,12 +19,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -77,7 +78,7 @@ class StoriesOfArdaComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_storiesonlinenet.py b/fanficfare/adapters/adapter_storiesonlinenet.py
index 4ada3b52..f7b9e744 100644
--- a/fanficfare/adapters/adapter_storiesonlinenet.py
+++ b/fanficfare/adapters/adapter_storiesonlinenet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2013 Fanficdownloader team, 2015 FanFicFare team
+# Copyright 2013 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,12 +19,14 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
#
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -134,7 +136,7 @@ class StoriesOnlineNetAdapter(BaseSiteAdapter):
self.needToLogin = False
try:
data = self._fetchUrl(url+":i")
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code in (404, 410):
raise exceptions.StoryDoesNotExist("Code: %s: %s"%(e.code,self.url))
elif e.code == 401:
@@ -148,7 +150,7 @@ class StoriesOnlineNetAdapter(BaseSiteAdapter):
self.performLogin(url)
try:
data = self._fetchUrl(url+":i",usecache=False)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code in (404, 410):
raise exceptions.StoryDoesNotExist("Code: %s: %s"%(e.code,self.url))
elif e.code == 401:
@@ -264,7 +266,7 @@ class StoriesOnlineNetAdapter(BaseSiteAdapter):
page = page + 1
try:
data = self._fetchUrl(self.story.getList('authorUrl')[0] + "/" + unicode(page))
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.FailedToDownload("Story not found in Author's list--change Listings Theme back to "+self.getTheme())
asoup = self.make_soup(data)
diff --git a/fanficfare/adapters/adapter_sugarquillnet.py b/fanficfare/adapters/adapter_sugarquillnet.py
index 739f92bf..e64b629e 100644
--- a/fanficfare/adapters/adapter_sugarquillnet.py
+++ b/fanficfare/adapters/adapter_sugarquillnet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -30,13 +30,16 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
import sys
from bs4.element import Comment
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -89,7 +92,7 @@ class SugarQuillNetAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(url)
else:
@@ -127,7 +130,7 @@ class SugarQuillNetAdapter(BaseSiteAdapter):
logger.debug('Getting the author page: {0}'.format(author_Url))
try:
adata = self._fetchUrl(author_Url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code in 404:
raise exceptions.StoryDoesNotExist("Author Page: Code: 404. {0}".format(author_Url))
elif e.code == 410:
diff --git a/fanficfare/adapters/adapter_swordborderlineangelcom.py b/fanficfare/adapters/adapter_swordborderlineangelcom.py
index e58274bf..3b2cfd09 100644
--- a/fanficfare/adapters/adapter_swordborderlineangelcom.py
+++ b/fanficfare/adapters/adapter_swordborderlineangelcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2017 FanFicFare team
+# Copyright 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_tasteofpoisoninkubationnet.py b/fanficfare/adapters/adapter_tasteofpoisoninkubationnet.py
index 0a6c717b..3ad19ac4 100644
--- a/fanficfare/adapters/adapter_tasteofpoisoninkubationnet.py
+++ b/fanficfare/adapters/adapter_tasteofpoisoninkubationnet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_tenhawkpresentscom.py b/fanficfare/adapters/adapter_tenhawkpresentscom.py
index e9a5da95..c65f23a1 100644
--- a/fanficfare/adapters/adapter_tenhawkpresentscom.py
+++ b/fanficfare/adapters/adapter_tenhawkpresentscom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -21,12 +21,13 @@ import logging
logger = logging.getLogger(__name__)
import re
import urllib
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
class TenhawkPresentsComSiteAdapter(BaseSiteAdapter):
@@ -111,7 +112,7 @@ class TenhawkPresentsComSiteAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_test1.py b/fanficfare/adapters/adapter_test1.py
index 74a87dab..7d0f02b4 100644
--- a/fanficfare/adapters/adapter_test1.py
+++ b/fanficfare/adapters/adapter_test1.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_tgstorytimecom.py b/fanficfare/adapters/adapter_tgstorytimecom.py
index ddc950f9..69bcd962 100644
--- a/fanficfare/adapters/adapter_tgstorytimecom.py
+++ b/fanficfare/adapters/adapter_tgstorytimecom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2015 FanFicFare team
+# Copyright 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_thebrokenworldorg.py b/fanficfare/adapters/adapter_thebrokenworldorg.py
index a32c350a..d4133b51 100644
--- a/fanficfare/adapters/adapter_thebrokenworldorg.py
+++ b/fanficfare/adapters/adapter_thebrokenworldorg.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_thedelphicexpansecom.py b/fanficfare/adapters/adapter_thedelphicexpansecom.py
index 77a7ebc2..c634cbb5 100644
--- a/fanficfare/adapters/adapter_thedelphicexpansecom.py
+++ b/fanficfare/adapters/adapter_thedelphicexpansecom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_thehookupzonenet.py b/fanficfare/adapters/adapter_thehookupzonenet.py
index 30aca527..285ff594 100644
--- a/fanficfare/adapters/adapter_thehookupzonenet.py
+++ b/fanficfare/adapters/adapter_thehookupzonenet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2015 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_themaplebookshelf.py b/fanficfare/adapters/adapter_themaplebookshelf.py
index 05ea1f59..e9affbf9 100644
--- a/fanficfare/adapters/adapter_themaplebookshelf.py
+++ b/fanficfare/adapters/adapter_themaplebookshelf.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2014 Fanficdownloader team, 2015 FanFicFare team
+# Copyright 2014 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_themasquenet.py b/fanficfare/adapters/adapter_themasquenet.py
index c914b975..ee69babf 100644
--- a/fanficfare/adapters/adapter_themasquenet.py
+++ b/fanficfare/adapters/adapter_themasquenet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -129,7 +130,7 @@ class TheMasqueNetAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -154,7 +155,7 @@ class TheMasqueNetAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_thepetulantpoetesscom.py b/fanficfare/adapters/adapter_thepetulantpoetesscom.py
index 436eccbd..e22b3ecb 100644
--- a/fanficfare/adapters/adapter_thepetulantpoetesscom.py
+++ b/fanficfare/adapters/adapter_thepetulantpoetesscom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -112,7 +113,7 @@ class ThePetulantPoetessComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_thundercatsfansorg.py b/fanficfare/adapters/adapter_thundercatsfansorg.py
index 05beaf1e..534fdddd 100644
--- a/fanficfare/adapters/adapter_thundercatsfansorg.py
+++ b/fanficfare/adapters/adapter_thundercatsfansorg.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_tolkienfanfiction.py b/fanficfare/adapters/adapter_tolkienfanfiction.py
index 2455b1ad..de09296b 100644
--- a/fanficfare/adapters/adapter_tolkienfanfiction.py
+++ b/fanficfare/adapters/adapter_tolkienfanfiction.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Copyright 2014 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2014 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -59,15 +59,18 @@ import time
import logging
logger = logging.getLogger(__name__)
import re
-import urllib
-import urllib2
-import urlparse
import string
from bs4.element import Comment
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib import parse as urlparse
+from ..six.moves.urllib.error import HTTPError
+from ..six.moves import urllib
+
from .base_adapter import BaseSiteAdapter, makeDate
def _is_story_url(url):
@@ -131,7 +134,7 @@ class TolkienFanfictionAdapter(BaseSiteAdapter):
chapterSoup = self.make_soup(chapterHtml)
indexLink = chapterSoup.find("a", text="[Index]")
self._normalizeURL('http://' + self.getSiteDomain() + '/' + indexLink.get('href'))
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -141,7 +144,7 @@ class TolkienFanfictionAdapter(BaseSiteAdapter):
try:
indexHtml = _fix_broken_markup(self._fetchUrl(self.url))
soup = self.make_soup(indexHtml)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -207,7 +210,7 @@ class TolkienFanfictionAdapter(BaseSiteAdapter):
date = searchSoup.find(text="Updated:").nextSibling.string
logger.debug("Last Updated: '%s'" % date)
self.story.setMetadata('dateUpdated', makeDate(date, self.dateformat))
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_tomparisdormcom.py b/fanficfare/adapters/adapter_tomparisdormcom.py
index fd3a584b..169c757a 100644
--- a/fanficfare/adapters/adapter_tomparisdormcom.py
+++ b/fanficfare/adapters/adapter_tomparisdormcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,13 +20,16 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
import sys
from bs4.element import Comment
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -79,7 +82,7 @@ class TomParisDormComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(url)
else:
diff --git a/fanficfare/adapters/adapter_trekfanfictionnet.py b/fanficfare/adapters/adapter_trekfanfictionnet.py
index e92fbc63..1304e4f2 100644
--- a/fanficfare/adapters/adapter_trekfanfictionnet.py
+++ b/fanficfare/adapters/adapter_trekfanfictionnet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -28,7 +28,9 @@ This will scrape the chapter text and metadata from stories on the site trekfanf
'''
import logging
import re
-import urllib2
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
from .base_adapter import BaseSiteAdapter, makeDate
@@ -92,7 +94,7 @@ class TrekFanFictionNetSiteAdapter(BaseSiteAdapter):
'''
try:
page_data = self._fetchUrl(page)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist('404 error: {}'.format(page))
else:
diff --git a/fanficfare/adapters/adapter_trekiverseorg.py b/fanficfare/adapters/adapter_trekiverseorg.py
index e13b6b69..7dd98a60 100644
--- a/fanficfare/adapters/adapter_trekiverseorg.py
+++ b/fanficfare/adapters/adapter_trekiverseorg.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2013 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2013 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,12 +19,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -126,7 +127,7 @@ class TrekiverseOrgAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
@@ -151,7 +152,7 @@ class TrekiverseOrgAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_tthfanficorg.py b/fanficfare/adapters/adapter_tthfanficorg.py
index c7d07f6c..bbed206f 100644
--- a/fanficfare/adapters/adapter_tthfanficorg.py
+++ b/fanficfare/adapters/adapter_tthfanficorg.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,10 +19,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
class TwistingTheHellmouthSiteAdapter(BaseSiteAdapter):
@@ -149,7 +152,7 @@ class TwistingTheHellmouthSiteAdapter(BaseSiteAdapter):
data = self._fetchUrl(url)
#print("data:%s"%data)
soup = self.make_soup(data)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code in (404,410):
raise exceptions.StoryDoesNotExist(url)
else:
@@ -199,7 +202,7 @@ class TwistingTheHellmouthSiteAdapter(BaseSiteAdapter):
#logger.info("authsoup:%s"%authorsoup)
descurl=nextpage
authorsoup = self.make_soup(authordata)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(url)
else:
@@ -236,7 +239,7 @@ class TwistingTheHellmouthSiteAdapter(BaseSiteAdapter):
stripHTML(a),
stripHTML(autha)),'https://'+self.host+a['href'])
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(url)
else:
diff --git a/fanficfare/adapters/adapter_twilightarchivescom.py b/fanficfare/adapters/adapter_twilightarchivescom.py
index 80ff8cb3..fde1cb8c 100644
--- a/fanficfare/adapters/adapter_twilightarchivescom.py
+++ b/fanficfare/adapters/adapter_twilightarchivescom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,12 +19,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -78,7 +79,7 @@ class TwilightArchivesComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_twilightednet.py b/fanficfare/adapters/adapter_twilightednet.py
index e0803659..959a239e 100644
--- a/fanficfare/adapters/adapter_twilightednet.py
+++ b/fanficfare/adapters/adapter_twilightednet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -21,12 +21,13 @@ import logging
logger = logging.getLogger(__name__)
import re
import urllib
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
class TwilightedNetSiteAdapter(BaseSiteAdapter):
@@ -101,7 +102,7 @@ class TwilightedNetSiteAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_unknowableroomorg.py b/fanficfare/adapters/adapter_unknowableroomorg.py
index 4fb51199..b8ec3f50 100644
--- a/fanficfare/adapters/adapter_unknowableroomorg.py
+++ b/fanficfare/adapters/adapter_unknowableroomorg.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2017 FanFicFare team
+# Copyright 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -21,9 +21,12 @@ from __future__ import absolute_import
''' This adapter will download stories from the site unknowableroom.org '''
import logging
import re
-import urllib2
import sys
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
from .. import exceptions as exceptions
@@ -83,7 +86,7 @@ class UnknowableRoomOrgSiteAdapter(BaseSiteAdapter):
'''
try:
page_data = self._fetchUrl(page)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist('404 error: {}'.format(page))
else:
diff --git a/fanficfare/adapters/adapter_valentchambercom.py b/fanficfare/adapters/adapter_valentchambercom.py
index 0d067759..ba35317d 100644
--- a/fanficfare/adapters/adapter_valentchambercom.py
+++ b/fanficfare/adapters/adapter_valentchambercom.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
-# Copyright 2015 FanFicFare team
-# Copyright 2016 FanFicFare team
+# Copyright 2018 FanFicFare team
+# Copyright 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_voracity2eficcom.py b/fanficfare/adapters/adapter_voracity2eficcom.py
index e1108ee9..8a47b2d5 100644
--- a/fanficfare/adapters/adapter_voracity2eficcom.py
+++ b/fanficfare/adapters/adapter_voracity2eficcom.py
@@ -1,11 +1,14 @@
# Software: eFiction
from __future__ import absolute_import
import re
-import urllib2
-import urlparse
from bs4.element import Tag
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib import parse as urlparse
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
from .. import exceptions
@@ -81,7 +84,7 @@ class Voracity2EficComAdapter(BaseSiteAdapter):
if exception:
try:
data = self._fetchUrl(url, parameters)
- except urllib2.HTTPError:
+ except HTTPError:
raise exception(self.url)
# Just let self._fetchUrl throw the exception, don't catch and
# customize it.
diff --git a/fanficfare/adapters/adapter_walkingtheplankorg.py b/fanficfare/adapters/adapter_walkingtheplankorg.py
index 930d9920..73e36f82 100644
--- a/fanficfare/adapters/adapter_walkingtheplankorg.py
+++ b/fanficfare/adapters/adapter_walkingtheplankorg.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -86,7 +87,7 @@ class WalkingThePlankOrgAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_wattpadcom.py b/fanficfare/adapters/adapter_wattpadcom.py
index 5e23a9ac..2e6041e1 100644
--- a/fanficfare/adapters/adapter_wattpadcom.py
+++ b/fanficfare/adapters/adapter_wattpadcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_webnovelcom.py b/fanficfare/adapters/adapter_webnovelcom.py
index 38e61944..39b9744d 100644
--- a/fanficfare/adapters/adapter_webnovelcom.py
+++ b/fanficfare/adapters/adapter_webnovelcom.py
@@ -23,7 +23,9 @@ import json
import logging
import re
import time
-import urllib2
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
from .base_adapter import BaseSiteAdapter
from .. import exceptions as exceptions
@@ -101,7 +103,7 @@ class WWWWebNovelComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist('Error 404: {0}'.format(self.url))
else:
diff --git a/fanficfare/adapters/adapter_whoficcom.py b/fanficfare/adapters/adapter_whoficcom.py
index 517c73ed..983151e5 100644
--- a/fanficfare/adapters/adapter_whoficcom.py
+++ b/fanficfare/adapters/adapter_whoficcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,12 +20,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
class WhoficComSiteAdapter(BaseSiteAdapter):
@@ -60,7 +61,7 @@ class WhoficComSiteAdapter(BaseSiteAdapter):
# use BeautifulSoup HTML parser to make everything easier to find.
try:
soup = self.make_soup(self._fetchUrl(url))
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_wolverineandroguecom.py b/fanficfare/adapters/adapter_wolverineandroguecom.py
index f2733bf5..ca10f248 100644
--- a/fanficfare/adapters/adapter_wolverineandroguecom.py
+++ b/fanficfare/adapters/adapter_wolverineandroguecom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,12 +19,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -78,7 +79,7 @@ class WolverineAndRogueComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_wraithbaitcom.py b/fanficfare/adapters/adapter_wraithbaitcom.py
index 491424bc..095602b8 100644
--- a/fanficfare/adapters/adapter_wraithbaitcom.py
+++ b/fanficfare/adapters/adapter_wraithbaitcom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,12 +19,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
@@ -87,7 +88,7 @@ class WraithBaitComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_writingwhimsicalwanderingsnet.py b/fanficfare/adapters/adapter_writingwhimsicalwanderingsnet.py
index 6ca24192..fe4f8274 100644
--- a/fanficfare/adapters/adapter_writingwhimsicalwanderingsnet.py
+++ b/fanficfare/adapters/adapter_writingwhimsicalwanderingsnet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,13 +20,16 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
import sys
from bs4.element import Comment
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -84,7 +87,7 @@ class WritingWhimsicalwanderingsNetAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url+addurl)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(url)
else:
diff --git a/fanficfare/adapters/adapter_wuxiaworldco.py b/fanficfare/adapters/adapter_wuxiaworldco.py
index b5d69105..a84f4ea4 100644
--- a/fanficfare/adapters/adapter_wuxiaworldco.py
+++ b/fanficfare/adapters/adapter_wuxiaworldco.py
@@ -19,8 +19,10 @@
from __future__ import absolute_import
import logging
import re
-import urllib2
-import urlparse
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib import parse as urlparse
+from ..six.moves.urllib.error import HTTPError
from .base_adapter import BaseSiteAdapter, makeDate
from fanficfare.htmlcleanup import stripHTML
@@ -68,7 +70,7 @@ class WuxiaWorldCoSiteAdapter(BaseSiteAdapter):
logger.debug('URL: %s', self.url)
try:
data = self._fetchUrl(self.url)
- except urllib2.HTTPError, exception:
+ except HTTPError as exception:
if exception.code == 404:
raise exceptions.StoryDoesNotExist('404 error: {}'.format(self.url))
raise exception
diff --git a/fanficfare/adapters/adapter_wuxiaworldcom.py b/fanficfare/adapters/adapter_wuxiaworldcom.py
index 83a11ba9..9bb3263e 100644
--- a/fanficfare/adapters/adapter_wuxiaworldcom.py
+++ b/fanficfare/adapters/adapter_wuxiaworldcom.py
@@ -20,8 +20,10 @@ from __future__ import absolute_import
import json
import logging
import re
-import urllib2
-import urlparse
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib import parse as urlparse
+from ..six.moves.urllib.error import HTTPError
from .base_adapter import BaseSiteAdapter, makeDate
from ..htmlcleanup import stripHTML
@@ -79,7 +81,7 @@ class WuxiaWorldComSiteAdapter(BaseSiteAdapter):
logger.debug('URL: %s', self.url)
try:
data = self._fetchUrl(self.url)
- except urllib2.HTTPError, exception:
+ except HTTPError as exception:
if exception.code == 404:
raise exceptions.StoryDoesNotExist('404 error: {}'.format(self.url))
raise exception
diff --git a/fanficfare/adapters/adapter_www13hoursorg.py b/fanficfare/adapters/adapter_www13hoursorg.py
index 7e5cff09..4c92cc4f 100644
--- a/fanficfare/adapters/adapter_www13hoursorg.py
+++ b/fanficfare/adapters/adapter_www13hoursorg.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_wwwaneroticstorycom.py b/fanficfare/adapters/adapter_wwwaneroticstorycom.py
index 9743106b..4e6414e7 100644
--- a/fanficfare/adapters/adapter_wwwaneroticstorycom.py
+++ b/fanficfare/adapters/adapter_wwwaneroticstorycom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2013 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2013 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,11 +20,13 @@ import logging
import os
import re
import sys
-import urllib2
-import urlparse
-
from bs4.element import Comment
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib import parse as urlparse
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
from .. import exceptions as exceptions
@@ -94,7 +96,7 @@ class WWWAnEroticStoryComAdapter(BaseSiteAdapter):
#strip comments and scripts from soup
[comment.extract() for comment in soup1.find_all(text=lambda text:isinstance(text, Comment))]
[script.extract() for script in soup1.find_all('script')]
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_wwwarea52hkhnet.py b/fanficfare/adapters/adapter_wwwarea52hkhnet.py
index b0133952..fccee9c4 100644
--- a/fanficfare/adapters/adapter_wwwarea52hkhnet.py
+++ b/fanficfare/adapters/adapter_wwwarea52hkhnet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -28,11 +28,13 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
-
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -96,7 +98,7 @@ class WWWArea52HKHNetAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist(self.url)
else:
diff --git a/fanficfare/adapters/adapter_wwwgiantessworldnet.py b/fanficfare/adapters/adapter_wwwgiantessworldnet.py
index 9945e205..b44938c3 100644
--- a/fanficfare/adapters/adapter_wwwgiantessworldnet.py
+++ b/fanficfare/adapters/adapter_wwwgiantessworldnet.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2016 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/adapter_wwwlushstoriescom.py b/fanficfare/adapters/adapter_wwwlushstoriescom.py
index 038b7e8f..36ac32fc 100644
--- a/fanficfare/adapters/adapter_wwwlushstoriescom.py
+++ b/fanficfare/adapters/adapter_wwwlushstoriescom.py
@@ -24,12 +24,16 @@ from __future__ import absolute_import
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
from bs4 import Comment, BeautifulSoup
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+from ..six.moves.urllib.parse import quote
+
from .base_adapter import BaseSiteAdapter, makeDate
####################################################################################################
@@ -57,12 +61,12 @@ class WWWLushStoriesComAdapter(BaseSiteAdapter): # XXX
if '%' not in storyId:
## assume already escaped if contains %. Assume needs escaping if it doesn't.
try:
- storyId = urllib2.quote(storyId)
+ storyId = quote(storyId)
except KeyError:
## string from calibre is utf8, but lushstories.com
## expects extended chars to be in latin1 / iso-8859-1
## rather than utf8.
- storyId = urllib2.quote(storyId.encode("iso-8859-1"))
+ storyId = quote(storyId.encode("iso-8859-1"))
self.story.setMetadata('storyId',storyId)
@@ -119,7 +123,7 @@ class WWWLushStoriesComAdapter(BaseSiteAdapter): # XXX
'''
try:
page_data = self._fetchUrl(page)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist('404 error: {}'.format(page))
else:
@@ -173,7 +177,7 @@ class WWWLushStoriesComAdapter(BaseSiteAdapter): # XXX
authorurl = self.story.getMetadata('authorUrl')
try:
adata = self._fetchUrl(authorurl)
- except (urllib2.HTTPError) as e:
+ except (HTTPError) as e:
## Can't get the author's page, so we use what is on the story page
tags = soup.find('div',{'id':'storytags'}).find('a')
if tags:
@@ -207,7 +211,7 @@ class WWWLushStoriesComAdapter(BaseSiteAdapter): # XXX
for story in asoup.findAll('div',{'class':'entrycontent'}):
for link in story.find_all('a'):
if '/stories/' in link['href']:
- linkh = urllib2.quote(link['href'].encode('utf-8', 'ignore'))
+ linkh = quote(link['href'].encode('utf-8', 'ignore'))
linkh = linkh.replace('%3A', ':')
# print self.url
# print linkh
diff --git a/fanficfare/adapters/adapter_wwwnovelallcom.py b/fanficfare/adapters/adapter_wwwnovelallcom.py
index 00e58f8d..d61e3593 100644
--- a/fanficfare/adapters/adapter_wwwnovelallcom.py
+++ b/fanficfare/adapters/adapter_wwwnovelallcom.py
@@ -23,8 +23,10 @@ from __future__ import absolute_import
import logging
import re
import json
-import urllib2
-import urlparse
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib import parse as urlparse
+from ..six.moves.urllib.error import HTTPError
from .base_adapter import BaseSiteAdapter, makeDate
@@ -109,7 +111,7 @@ class WWWNovelAllComAdapter(BaseSiteAdapter):
try:
data = self._fetchUrl(url)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist('404 error: {}'.format(url))
else:
diff --git a/fanficfare/adapters/adapter_wwwutopiastoriescom.py b/fanficfare/adapters/adapter_wwwutopiastoriescom.py
index 8226e970..fab7711b 100644
--- a/fanficfare/adapters/adapter_wwwutopiastoriescom.py
+++ b/fanficfare/adapters/adapter_wwwutopiastoriescom.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2012 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2012 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -32,13 +32,18 @@ We get the category from the author's page
import logging
logger = logging.getLogger(__name__)
import re
-import urllib2
import sys
from bs4.element import Comment
+
from ..htmlcleanup import stripHTML
from .. import exceptions as exceptions
+# py2 vs py3 transition
+from ..six import text_type as unicode
+from ..six.moves.urllib.error import HTTPError
+from ..six.moves.urllib.parse import quote
+
from .base_adapter import BaseSiteAdapter, makeDate
def getClass():
@@ -95,7 +100,7 @@ class WWWUtopiastoriesComAdapter(BaseSiteAdapter):
'''
try:
page_data = self._fetchUrl(page)
- except urllib2.HTTPError, e:
+ except HTTPError as e:
if e.code == 404:
raise exceptions.StoryDoesNotExist('404 error: {}'.format(page))
else:
@@ -155,7 +160,7 @@ class WWWUtopiastoriesComAdapter(BaseSiteAdapter):
else:
self.story.setMetadata('authorId',a['href'].split('/')[2])
self.story.setMetadata('author',a.string)
- self.story.setMetadata('authorUrl','http://'+self.host+urllib2.quote(
+ self.story.setMetadata('authorUrl','http://'+self.host+quote(
a['href'].encode('UTF-8')))
elif 'Story Codes' in heading:
self.story.setMetadata('eroticatags',text.replace('Story Codes - ',''))
diff --git a/fanficfare/adapters/base_adapter.py b/fanficfare/adapters/base_adapter.py
index 6c90520a..fb7e02c1 100644
--- a/fanficfare/adapters/base_adapter.py
+++ b/fanficfare/adapters/base_adapter.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2017 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/fanficfare/adapters/base_xenforoforum_adapter.py b/fanficfare/adapters/base_xenforoforum_adapter.py
index b5549495..0773b7c0 100644
--- a/fanficfare/adapters/base_xenforoforum_adapter.py
+++ b/fanficfare/adapters/base_xenforoforum_adapter.py
@@ -21,13 +21,13 @@ logger = logging.getLogger(__name__)
import re
from xml.dom.minidom import parseString
+from ..htmlcleanup import stripHTML
+from .. import exceptions as exceptions
+
# py2 vs py3 transition
from ..six import text_type as unicode
from ..six.moves.urllib.error import HTTPError
-from ..htmlcleanup import stripHTML
-from .. import exceptions as exceptions
-
from .base_adapter import BaseSiteAdapter, makeDate
logger = logging.getLogger(__name__)
diff --git a/fanficfare/dateutils.py b/fanficfare/dateutils.py
index 2716e253..1caf0a3f 100644
--- a/fanficfare/dateutils.py
+++ b/fanficfare/dateutils.py
@@ -22,7 +22,7 @@ from datetime import datetime, timedelta
import logging
logger = logging.getLogger(__name__)
-UNIX_EPOCHE = datetime.fromtimestamp(0)
+UNIX_EPOCHE = datetime.fromtimestamp(86400)
## Currently used by adapter_webnovelcom & adapter_wwwnovelallcom
diff --git a/fanficfare/geturls.py b/fanficfare/geturls.py
index d0175830..de0fff41 100644
--- a/fanficfare/geturls.py
+++ b/fanficfare/geturls.py
@@ -20,11 +20,11 @@ import collections
import email
import imaplib
import re
+
+# unicode in py2, str in py3
from .six.moves.urllib.request import (build_opener, HTTPCookieProcessor)
from .six.moves.urllib.parse import (urlparse, urlunparse)
-# unicode in py2, str in py3
from .six import text_type as unicode
-
from .six import ensure_str
import logging
diff --git a/fanficfare/writers/__init__.py b/fanficfare/writers/__init__.py
index 0d378170..f1cb1325 100644
--- a/fanficfare/writers/__init__.py
+++ b/fanficfare/writers/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2011 Fanficdownloader team, 2015 FanFicFare team
+# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.