Repository: pymedusa/Medusa

Issue:
[APP SUBMITTED]: AttributeError: 'NoneType' object has no attribute 'group'

### INFO
**Python Version**: `2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)]`
**Operating System**: `Windows-10-10.0.17763`
**Locale**: `cp1252`
**Branch**: [master](../tree/master)
**Database**: `44.14`
**Commit**: pymedusa/Medusa@baad1e5af59d7f29606c1fed1c110af1424bb117
**Link to Log**: https://gist.github.com/0b07131025830241a11759886e104100
### ERROR
<pre>
2019-09-20 15:49:22 ERROR    SEARCHQUEUE-DAILY-SEARCH :: [AnimeBytes] :: [baad1e5] DailySearchQueueItem Exception, error: 'NoneType' object has no attribute 'group'
Traceback (most recent call last):
  File "C:\Medusa\Medusa\<a href="../blob/baad1e5af59d7f29606c1fed1c110af1424bb117/medusa/search/queue.py#L266">medusa\search\queue.py</a>", line 266, in run
    found_results = search_for_needed_episodes(self.scheduler_start_time, force=self.force)
  File "C:\Medusa\Medusa\<a href="../blob/baad1e5af59d7f29606c1fed1c110af1424bb117/medusa/search/core.py#L524">medusa\search\core.py</a>", line 524, in search_for_needed_episodes
    cur_provider.cache.update_cache(scheduler_start_time)
  File "C:\Medusa\Medusa\<a href="../blob/baad1e5af59d7f29606c1fed1c110af1424bb117/medusa/tv/cache.py#L207">medusa\tv\cache.py</a>", line 207, in update_cache
    data = self._get_rss_data()
  File "C:\Medusa\Medusa\<a href="../blob/baad1e5af59d7f29606c1fed1c110af1424bb117/medusa/tv/cache.py#L190">medusa\tv\cache.py</a>", line 190, in _get_rss_data
    return {'entries': self.provider.search(self.search_params)}
  File "C:\Medusa\Medusa\<a href="../blob/baad1e5af59d7f29606c1fed1c110af1424bb117/medusa/providers/torrent/json/animebytes.py#L111">medusa\providers\torrent\json\animebytes.py</a>", line 111, in search
    results += self.parse(jdata, mode)
  File "C:\Medusa\Medusa\<a href="../blob/baad1e5af59d7f29606c1fed1c110af1424bb117/medusa/providers/torrent/json/animebytes.py#L173">medusa\providers\torrent\json\animebytes.py</a>", line 173, in parse
    episode = re.match(r'Episodes 1-(\d+)', title_info).group(1)
AttributeError: 'NoneType' object has no attribute 'group'
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators



Discussion:
Sadly we don't have access to this provider anymore. If this is a recurrent issue, please help us by providing temporary access to the provider.
I am willing to give temp access to the provider
Pm on discord
Theonepudding#2189
@theoneglenn https://discord.gg/zMdAdUK
I'ts hard to reproduce. But the issue is (i think) in the asumption that a multi-ep release always starts with ep1. `episode = re.match(r'Episodes 1-(\d+)', title_info).group(1)`

So I don't know if that's possible. But a release like `Episodes 123-245`, might result in the exception.

Resolving patch:
diff --git a/medusa/providers/torrent/json/animebytes.py b/medusa/providers/torrent/json/animebytes.py
--- a/medusa/providers/torrent/json/animebytes.py
+++ b/medusa/providers/torrent/json/animebytes.py
@@ -164,13 +164,18 @@ def parse(self, data, mode):
                 release_type = OTHER
                 season = None
                 episode = None
+                multi_ep_start = None
+                multi_ep_end = None
                 title = None
 
-                # Attempt and get an season or episode number
+                # Attempt and get a season or episode number
                 title_info = row.get('EditionData').get('EditionTitle')
                 if title_info != '':
                     if title_info.startswith('Episodes'):
-                        episode = re.match(r'Episodes 1-(\d+)', title_info).group(1)
+                        multi_ep_match = re.match(r'Episodes (\d+)-(\d+)', title_info)
+                        if multi_ep_match:
+                            multi_ep_start = multi_ep_match.group(1)
+                            multi_ep_end = multi_ep_match.group(2)
                         release_type = MULTI_EP
                     elif title_info.startswith('Episode'):
                         episode = re.match('^Episode.([0-9]+)', title_info).group(1)
@@ -208,10 +213,11 @@ def parse(self, data, mode):
                 if release_type == MULTI_EP:
                     # Create the multi-episode release_name
                     # Multiple.Episode.TV.Show.SXXEXX-EXX[Episode.Part].[Episode.Title].TAGS.[LANGUAGE].720p.FORMAT.x264-GROUP
-                    title = '{title}.{season}{multi_episode}.{tags}' \
+                    title = '{title}.{season}{multi_episode_start}-{multi_episode_end}.{tags}' \
                             '{release_group}'.format(title=group.get('SeriesName'),
                                                      season='S{0}'.format(season) if season else 'S01',
-                                                     multi_episode='E01-E{0}'.format(episode),
+                                                     multi_episode_start='E{0}'.format(multi_ep_start),
+                                                     multi_episode_end='E{0}'.format(multi_ep_end),
                                                      tags=tags,
                                                      release_group=release_group)
                 if release_type == SEASON_PACK:


Test patch: