Repository: Flexget/Flexget

Issue:
Series Forget by date doesn't work 
<!---
Before opening an issue, verify:

- Is this a feature request? Post it on https://feathub.com/Flexget/Flexget
- Did you recently upgrade? Look at the Change Log and Upgrade Actions to make sure that you don't need to make any changes to your config https://flexget.com/ChangeLog https://flexget.com/UpgradeActions
- Are you running FlexGet as a daemon? Stop it completely and then start it again https://flexget.com/CLI/daemon
- Did you search to see if the issue already exists? https://github.com/Flexget/Flexget/issues
- Did you fill out the issue template as completely as possible?

The issue template is here because it helps to ensure you submitted all the necessary information the first time, and allows us to more quickly review issues. Please fill it out correctly and do not ignore it, no matter how irrelevant you think it may be. Thanks in advance for your help with this!
--->
### Expected behaviour:
I have a series that is identified by date. I'm trying to use the command `series forget 'WWE Raw' '2018-07-23'` will remove the episode from the database.

### Actual behaviour:
I get an error saying `Unknown identifier '2018-07-23' for series 'WWE Raw'`

I tried multiple formats for the dates and different orders for the year/month/day and get the same result.

### Additional information:

- FlexGet version: 2.14.9
- Python version: 2.7.12
- Installation method: pip
- Using daemon (yes/no): no
- OS and version: Ubuntu Server 16.04.5
Series Forget by date doesn't work 
<!---
Before opening an issue, verify:

- Is this a feature request? Post it on https://feathub.com/Flexget/Flexget
- Did you recently upgrade? Look at the Change Log and Upgrade Actions to make sure that you don't need to make any changes to your config https://flexget.com/ChangeLog https://flexget.com/UpgradeActions
- Are you running FlexGet as a daemon? Stop it completely and then start it again https://flexget.com/CLI/daemon
- Did you search to see if the issue already exists? https://github.com/Flexget/Flexget/issues
- Did you fill out the issue template as completely as possible?

The issue template is here because it helps to ensure you submitted all the necessary information the first time, and allows us to more quickly review issues. Please fill it out correctly and do not ignore it, no matter how irrelevant you think it may be. Thanks in advance for your help with this!
--->
### Expected behaviour:
I have a series that is identified by date. I'm trying to use the command `series forget 'WWE Raw' '2018-07-23'` will remove the episode from the database.

### Actual behaviour:
I get an error saying `Unknown identifier '2018-07-23' for series 'WWE Raw'`

I tried multiple formats for the dates and different orders for the year/month/day and get the same result.

### Additional information:

- FlexGet version: 2.14.9
- Python version: 2.7.12
- Installation method: pip
- Using daemon (yes/no): no
- OS and version: Ubuntu Server 16.04.5


Discussion:
Reproduced and pinpointed the issue. Did this ever work? Looks like it hasn't at least since season packs were introduced a year and a half ago.
Reproduced and pinpointed the issue. Did this ever work? Looks like it hasn't at least since season packs were introduced a year and a half ago.

Resolving patch:
diff --git a/flexget/plugins/filter/series.py b/flexget/plugins/filter/series.py
--- a/flexget/plugins/filter/series.py
+++ b/flexget/plugins/filter/series.py
@@ -1125,8 +1125,12 @@ def remove_entity(entity):
                 removed = True
                 downloaded_releases = remove_entity(season)
         else:
-            episode = session.query(Episode).filter(Episode.season == parsed.season).filter(
-                Episode.number == parsed.episode).filter(Episode.series_id == series.id).first()
+            episode = session.query(Episode).filter(Episode.series_id == series.id)
+            if parsed.episode:
+                episode = episode.filter(Episode.number == parsed.episode).filter(Episode.season == parsed.season)
+            else:
+                episode = episode.filter(Episode.identifier == parsed.identifier)
+            episode = episode.first()
             if episode:
                 removed = True
                 downloaded_releases = remove_entity(episode)


Test patch: