Repository: pymedusa/Medusa

Issue:
No published date for IPtorrent
Medusa Info: | Version
-- | --
Branch: | master                
Commit: | ca2c5c4c92888f2f588c74c6770cfa12c6db7f40                
Version: | v0.1.19                
Database: | 44.8
Python Version: | 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)]
SSL Version: | OpenSSL 1.0.2j  26 Sep 2016
OS: | Windows-10-10.0.14393
Locale: | nl_NL.cp1252

Not sure if this is a bug or working as designed.
When I do a manual search the Publish Dates for IPtorrents are not populated.
![image](https://user-images.githubusercontent.com/4103090/33559465-23f5266e-d90d-11e7-97a9-3c6b6e837070.png)




Discussion:
It has never been implemented, probably with a reason.
Is there are torrent publish data available?
The publish date is there (human time). I think the main reason was laziness 😃 
Aah, ok.
Well @rouzax, i guess won't be long before that's added.

Resolving patch:
diff --git a/medusa/providers/generic_provider.py b/medusa/providers/generic_provider.py
--- a/medusa/providers/generic_provider.py
+++ b/medusa/providers/generic_provider.py
@@ -587,8 +587,15 @@ def parse_pubdate(pubdate, human_time=False, timezone=None, **kwargs):
                 if pubdate.lower() in now_alias:
                     seconds = 0
                 else:
-                    match = re.search(r'(?P<time>\d+\W*\w+)', pubdate)
-                    seconds = parse(match.group('time'))
+                    match = re.search(r'(?P<time>[\d.]+\W*)(?P<granularity>\w+)', pubdate)
+                    matched_time = match.group('time')
+                    matched_granularity = match.group('granularity')
+
+                    # The parse method does not support decimals used with the month, months, year or years granularities.
+                    if matched_granularity and matched_granularity in ('month', 'months', 'year', 'years'):
+                        matched_time = int(round(float(matched_time.strip())))
+
+                    seconds = parse('{0} {1}'.format(matched_time, matched_granularity))
                 return datetime.now(tz.tzlocal()) - timedelta(seconds=seconds)
 
             dt = parser.parse(pubdate, dayfirst=df, yearfirst=yf, fuzzy=True)
diff --git a/medusa/providers/torrent/html/iptorrents.py b/medusa/providers/torrent/html/iptorrents.py
--- a/medusa/providers/torrent/html/iptorrents.py
+++ b/medusa/providers/torrent/html/iptorrents.py
@@ -132,13 +132,16 @@ def parse(self, data, mode):
                     torrent_size = row('td')[5].text
                     size = convert_size(torrent_size) or -1
 
+                    pubdate_raw = row('td')[1].find('div').get_text().split('|')[-1].strip()
+                    pubdate = self.parse_pubdate(pubdate_raw, human_time=True)
+
                     item = {
                         'title': title,
                         'link': download_url,
                         'size': size,
                         'seeders': seeders,
                         'leechers': leechers,
-                        'pubdate': None,
+                        'pubdate': pubdate,
                     }
                     if mode != 'RSS':
                         log.debug('Found result: {0} with {1} seeders and {2} leechers',


Test patch:
diff --git a/tests/providers/test_generic_provider.py b/tests/providers/test_generic_provider.py
--- a/tests/providers/test_generic_provider.py
+++ b/tests/providers/test_generic_provider.py
@@ -88,6 +88,34 @@
         'dayfirst': True,
         'yearfirst': True
     },
+    {  # p15: iptorrents test human date with decimal.
+        'pubdate': '4.8 minutes ago',
+        'expected': 288,
+        'human_time': True
+    },
+    {  # p16: iptorrents test human date with decimal.
+        'pubdate': '4.2 weeks ago',
+        'expected': 2540160,
+        'human_time': True
+    },
+    {  # p17: iptorrents test human date with decimal.
+       # The parse method does not support decimals for the months granularity.
+        'pubdate': '1.0 months ago',
+        'expected': 2592000,
+        'human_time': True
+    },
+    {  # p18: iptorrents test human date with decimal. (round down)
+       # The parse method does not support decimals for the years granularity.
+        'pubdate': '5.2 years ago',
+        'expected': 157680000,
+        'human_time': True
+    },
+    {  # p19: iptorrents test human date with decimal. (round up)
+       # The parse method does not support decimals for the years granularity.
+        'pubdate': '4.8 years ago',
+        'expected': 157680000,
+        'human_time': True
+    },
 ])
 def test_parse_pubdate(p):
     # Given