daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Dec 15th, 2018 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. logging.basicConfig(level=logging.INFO)
  2.  
  3.  
  4. bot = Bot(token=API_TOKEN)
  5. dp = Dispatcher(bot)
  6.  
  7.  
  8. actions = None
  9. selected_movie = None
  10. buttons = None
  11. markup = None
  12. options = {}
  13. state = None
  14.  
  15.  
  16. def parse_movie_result(movie):
  17.     main_info = movie.findAll('a', {'class': 'list__item-name'})[0]
  18.     title = main_info.text
  19.     href = main_info.get('href')
  20.     genres_info, producer_info, *starring_info = movie.findAll('dd', {'class': 'list__item-desc'})
  21.     genres = ''.join(genres_info.text.strip().split()).split(',')
  22.     producer = producer_info.text.strip()
  23.     if len(starring_info):
  24.         starring = list(map(str.strip, starring_info[0].text.strip().split(',')))
  25.     else:
  26.         starring = []
  27.     country_date = movie.findAll('span', {'class': 'list__item-additionals'})[0].text
  28.     year, *countries = map(str.strip, country_date.split(','))
  29.     ratings = movie.findAll('div', {'class': 'rating-static'})
  30.     rating = None
  31.     if len(ratings):
  32.         rating = float(ratings[0].text)
  33.     movie_base = Movie(title=title, href=href, rating=rating, genres=genres, producer=producer,
  34.                        starring=starring, year=year, countries=countries)
  35.     return movie_base
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top