def buildMangaReply(searchText, isExpanded, baseComment): try: #Basic breakdown: #If Anilist finds something, use it to find the MAL version. #If hits either MAL or Ani, use it to find the MU version. #If it hits either, add it to the request-tracking DB. ani = Anilist.getMangaDetails(searchText) mal = None mu = None if not (ani is None): mal = MAL.getMangaDetails(ani['title_romaji']) else: mal = MAL.getMangaDetails(searchText) if not (mal is None): ani = Anilist.getMangaDetails(mal['title']) if (ani is not None) or (mal is not None): try: titleToAdd = '' if mal is not None: titleToAdd = mal['title'] mu = MU.getMangaURL(mal['title']) else: titleToAdd = ani['title_english'] mu = MU.getMangaURL(ani['title_romaji']) if (str(baseComment.subreddit).lower is not 'nihilate') and (str(baseComment.subreddit).lower is not 'roboragi'): DatabaseHandler.addRequest(titleToAdd, 'Manga', baseComment.author.name, baseComment.subreddit) except: traceback.print_exc() pass if ani is not None: if ani['adult'] is True: print("NSFW ENTRY") mal = None ani = None mu = None return CommentBuilder.buildMangaComment(isExpanded, mal, ani, mu) except Exception as e: traceback.print_exc() return None
def buildMangaReply(searchText, isExpanded, baseComment, blockTracking=False): try: ani = None mal = None mu = None ap = None try: sqlCur.execute('SELECT dbLinks FROM synonyms WHERE type = "Manga" and lower(name) = ?', [searchText.lower()]) except sqlite3.Error as e: print(e) alternateLinks = sqlCur.fetchone() if (alternateLinks): synonym = json.loads(alternateLinks[0]) if (synonym['mal']): mal = MAL.getMangaDetails(synonym['mal']) if (synonym['ani']): ani = Anilist.getMangaDetails(synonym['ani']) if (synonym['mu']): mu = MU.getMangaURL(synonym['mu']) if (synonym['ap']): ap = AniP.getMangaURL(synonym['ap']) else: #Basic breakdown: #If Anilist finds something, use it to find the MAL version. #If hits either MAL or Ani, use it to find the MU version. #If it hits either, add it to the request-tracking DB. ani = Anilist.getMangaDetails(searchText) if not (ani is None): mal = MAL.getMangaDetails(ani['title_romaji']) else: mal = MAL.getMangaDetails(searchText) if not (mal is None): ani = Anilist.getMangaDetails(mal['title']) #----- Finally... -----# if ani or mal: try: titleToAdd = '' if mal: titleToAdd = mal['title'] else: titleToAdd = ani['title_english'] if not alternateLinks: #MU stuff if mal: mu = MU.getMangaURL(mal['title']) else: mu = MU.getMangaURL(ani['title_romaji']) #Do the anime-planet stuff if mal and not ap: if mal['title'] and not ap: ap = AniP.getMangaURL(mal['title']) if mal['english'] and not ap: ap = AniP.getMangaURL(mal['english']) if mal['synonyms'] and not ap: for synonym in mal['synonyms']: if ap: break ap = AniP.getMangaURL(synonym) if ani and not ap: if ani['title_english'] and not ap: ap = AniP.getMangaURL(ani['title_english']) if ani['title_romaji'] and not ap: ap = AniP.getMangaURL(ani['title_romaji']) if ani['synonyms'] and not ap: for synonym in ani['synonyms']: if ap: break ap = AniP.getMangaURL(synonym) if (str(baseComment.subreddit).lower is not 'nihilate') and (str(baseComment.subreddit).lower is not 'roboragi') and not blockTracking: DatabaseHandler.addRequest(titleToAdd, 'Manga', baseComment.author.name, baseComment.subreddit) except: traceback.print_exc() pass if ani is not None: if ani['adult'] is True: mal = None ani = None mu = None ap = None return CommentBuilder.buildMangaComment(isExpanded, mal, ani, mu, ap) except Exception as e: traceback.print_exc() return None
def buildMangaReply(searchText, isExpanded, baseComment, blockTracking=False): try: ani = None mal = None mu = None ap = None try: sqlCur.execute( 'SELECT dbLinks FROM synonyms WHERE type = "Manga" and lower(name) = ?', [searchText.lower()]) except sqlite3.Error as e: print(e) alternateLinks = sqlCur.fetchone() if (alternateLinks): synonym = json.loads(alternateLinks[0]) if (synonym['mal']): mal = MAL.getMangaDetails(synonym['mal'][0], synonym['mal'][1]) if (synonym['ani']): ani = Anilist.getMangaDetailsById(synonym['ani']) if (synonym['mu']): mu = MU.getMangaURLById(synonym['mu']) if (synonym['ap']): ap = AniP.getMangaURLById(synonym['ap']) else: #Basic breakdown: #If Anilist finds something, use it to find the MAL version. #If hits either MAL or Ani, use it to find the MU version. #If it hits either, add it to the request-tracking DB. ani = Anilist.getMangaDetails(searchText) if ani: try: mal = MAL.getMangaDetails(ani['title_romaji']) except: pass if not mal: try: mal = MAL.getMangaDetails(ani['title_english']) except: pass if not mal: mal = MAL.getMangaDetails(searchText) else: mal = MAL.getMangaDetails(searchText) if mal: ani = Anilist.getMangaDetails(mal['title']) #----- Finally... -----# if ani or mal: try: titleToAdd = '' if mal: titleToAdd = mal['title'] else: try: titleToAdd = ani['title_english'] except: titleToAdd = ani['title_romaji'] if not alternateLinks: #MU stuff if mal: mu = MU.getMangaURL(mal['title']) else: mu = MU.getMangaURL(ani['title_romaji']) #Do the anime-planet stuff if mal and not ap: if mal['title'] and not ap: ap = AniP.getMangaURL(mal['title']) if mal['english'] and not ap: ap = AniP.getMangaURL(mal['english']) if mal['synonyms'] and not ap: for synonym in mal['synonyms']: if ap: break ap = AniP.getMangaURL(synonym) if ani and not ap: if ani['title_english'] and not ap: ap = AniP.getMangaURL(ani['title_english']) if ani['title_romaji'] and not ap: ap = AniP.getMangaURL(ani['title_romaji']) if ani['synonyms'] and not ap: for synonym in ani['synonyms']: if ap: break ap = AniP.getMangaURL(synonym) if (str(baseComment.subreddit).lower is not 'nihilate') and ( str(baseComment.subreddit).lower is not 'roboragi') and not blockTracking: DatabaseHandler.addRequest(titleToAdd, 'Manga', baseComment.author.name, baseComment.subreddit) except: traceback.print_exc() pass return CommentBuilder.buildMangaComment(isExpanded, mal, ani, mu, ap) except Exception as e: traceback.print_exc() return None