def get_lyric(artist,song,buf): logging.info("get_lyric:artist[%s]:song[%s]"%(artist,song)) scrapers = choose_scrapers(args.sites, artist, song) for scraper in scrapers: try: obj = scraper(artist,song,args.proxy) ret=obj.get_lyric() except Exception as e: logging.error(obj.log_msg("error:[%s]" % e)) continue if ret == True: buf.write(obj.lyric) return True logging.info("no lyrics at all sites") return False
print(s.site) sys.exit(0) read_config(args) logging.basicConfig(level=logging.INFO, stream=open("get_lyric.log", mode="w", encoding="utf-8")) logging.info("argument:" + str(args)) if args.artist is None or args.song is None: logging.info("artist and song is required.exit") sys.exit(0) scrapers = choose_scrapers(args.sites, args.artist, args.song) ret = False for scraper in scrapers: try: obj = scraper(args.artist, args.song, args.proxy) ret = obj.get_lyric() except Exception as e: logging.error(obj.log_msg("error:[%s]" % e)) continue if ret == True: print(obj.lyric, end="") break if ret == False: logging.info("no lyrics at all sites")
if args.list: for s in list_scrapers(): print(s.site) sys.exit(0) read_config(args) logging.basicConfig(level=logging.INFO, stream = open("get_lyric.log",mode="w",encoding="utf-8")) logging.info("argument:" + str(args)) if args.artist is None or args.song is None: logging.info("artist and song is required.exit") sys.exit(0) scrapers = choose_scrapers(args.sites, args.artist, args.song) ret = False for scraper in scrapers: try: obj = scraper(args.artist, args.song,args.proxy) ret=obj.get_lyric() except Exception as e: logging.error(obj.log_msg("error:[%s]" % e)) continue if ret == True: print(obj.lyric,end="") break if ret==False: logging.info("no lyrics at all sites")