Repository: pymedusa/Medusa

Issue:
Can't add new or existing Russian shows (Cyrillic names)
Tried to add several shows like “Мажор” and no luck. After clicking “Add” if shows “Show was added” toast message and I can see new show record with “Loading” status that stays forever. After page refresh the show is gone. BTW if I try to add show as new one, it creates folder with correct Unicode chars.
English shows like “Sopranos” are added just fine. Restarted Docker container and host several times.

**Logs:**
```
12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎18‎ ‎AM2018-12-19 10:28:18 INFO     SHOWQUEUE-ADD :: [54da0c7] Starting to add show by ShowDir: /tv/Мажор
‎12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎18‎ ‎AM2018-12-19 10:28:18 INFO     SHOWQUEUE-ADD :: [54da0c7] TVmaze: {u'session': <medusa.session.core.MedusaSession object at 0x7facc87799d0>, u'cache': u'/config/cache/indexers/TVmaze', u'language': u'en', u'use_zip': True}
‎12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎20‎ ‎AM2018-12-19 10:28:20 INFO     SHOWQUEUE-ADD :: [54da0c7] 3390: Unable to find the show in the database
‎12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎21‎ ‎AM2018-12-19 10:28:21 INFO     SHOWQUEUE-ADD :: [54da0c7] Setting all previously aired episodes to the specified status: Skipped
‎12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎21‎ ‎AMException in thread SHOWQUEUE-ADD:
‎12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎21‎ ‎AMTraceback (most recent call last):
‎12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎21‎ ‎AM  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
‎12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎21‎ ‎AM    self.run()
‎12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎21‎ ‎AM  File "/app/medusa/medusa/show_queue.py", line 589, in run
‎12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎21‎ ‎AM    self.show.load_imdb_info()
‎12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎21‎ ‎AM  File "/app/medusa/medusa/tv/series.py", line 1528, in load_imdb_info
‎12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎21‎ ‎AM    self.imdb_id = helpers.title_to_imdb(self.name, self.start_year, imdb_api)
‎12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎21‎ ‎AM  File "/app/medusa/medusa/helpers/__init__.py", line 1731, in title_to_imdb
‎12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎21‎ ‎AM    titles = imdb_api.search_for_title(title)
‎12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎21‎ ‎AM  File "/app/medusa/ext/imdbpie/imdbpie.py", line 182, in search_for_title
‎12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎21‎ ‎AM    search_results = self._suggest_search(title)
‎12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎21‎ ‎AM  File "/app/medusa/ext/imdbpie/imdbpie.py", line 155, in _suggest_search
‎12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎21‎ ‎AM    first_alphanum_char = self._query_first_alpha_num(cleaned_query)
‎12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎21‎ ‎AM  File "/app/medusa/ext/imdbpie/imdbpie.py", line 348, in _query_first_alpha_num
‎12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎21‎ ‎AM    'invalid query, does not contain any alphanumeric characters'
‎12‎/‎19‎/‎2018 ‎10‎:‎28‎:‎21‎ ‎AMValueError: invalid query, does not contain any alphanumeric characters
```
Docker version
Branch: master 
Commit: 54da0c77d705a23f1ce67945ba4af3e1b978dcfc 
Version: v0.2.13 
Database: 44.12



Discussion:
Thanks for the report!
This is a bug introduced recently by an upstream lib we use, imdbpie.

I will open a bug report upstream and also add a workaround in the coming days.
Yes, would be great if we can find workaround meanwhile. 
Maybe I can use earlier version of docker meanwhile? If so, please let me know what version should work.
Thank you for looking on this! 
@HippyRock If you know the tvdb id for the show, you should be able to add it via the API.  @medariox would you mind posting the API command for adding a show, as I'm not at home right now.
apiv2 command:
POST: http://localhost:9082/mywebroot/api/v2/series
body: `{
  "id":{
    "tvmaze": 3390
  }
}`

make sure to set your apiv2 api key in the `X-Api-Key` header.

But honestly, i doubt that will work.

Resolving patch:
diff --git a/medusa/helpers/__init__.py b/medusa/helpers/__init__.py
--- a/medusa/helpers/__init__.py
+++ b/medusa/helpers/__init__.py
@@ -1728,7 +1728,13 @@ def title_to_imdb(title, start_year, imdb_api=None):
     if imdb_api is None:
         imdb_api = Imdb()
 
-    titles = imdb_api.search_for_title(title)
+    try:
+        titles = imdb_api.search_for_title(title)
+    except ValueError as error:
+        # FIXME: Putting an error here, as this is a known error with the lib imdbpie. And should be fix.
+        log.warning('Could not get a result from imdbpie for the title {title}, error: {error}',
+                    {'title': title, 'error': error})
+        return None
 
     if len(titles) == 1:
         return titles[0]['imdb_id']


Test patch: