text: # -*- coding: utf-8 -*-
  """
      Catch-up TV & More
      Copyright (C) 2017  SylvainCecchetto
  
      This file is part of Catch-up TV & More.
  
      Catch-up TV & More is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published by
      the Free Software Foundation; either version 2 of the License, or
      (at your option) any later version.
  
      Catch-up TV & More is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU General Public License for more details.
  
      You should have received a copy of the GNU General Public License along
      with Catch-up TV & More; if not, write to the Free Software Foundation,
      Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  """
  
  # The unicode_literals import only has
  # an effect on Python 2.
  # It makes string literals as unicode like in Python 3
  from __future__ import unicode_literals
  
  from codequick import Route, Resolver, Listitem, utils, Script
  
  from resources.lib.labels import LABELS
  from resources.lib import web_utils
  
  import re
  import urlquick
  
  # TO DO
  # Replay add emissions
  # Add info LIVE TV
  
  URL_ROOT = 'http://www.dw.com'
  
  
  def live_entry(plugin, item_id, **kwargs):
      return get_live_url(plugin, item_id, item_id.upper())
  
  
  @Resolver.register
  def get_live_url(plugin, item_id, video_id, **kwargs):
      final_language = kwargs.get('language', Script.setting['dw.language'])
  
      stream_url = ''
      resp = urlquick.get(URL_ROOT + '/%s' % final_language.lower())
      list_lives_datas = re.compile(r'name="file_name" value="(.*?)"').findall(
          resp.text)
  
      for live_datas in list_lives_datas:
          if 'm3u8' in live_datas:
              stream_url = live_datas
      return stream_url
  