Skip to content

New lostfilm plugin#1681

Merged
liiight merged 4 commits intoFlexget:developfrom
Danfocus:Danfocus-patch-lostfilm
Feb 15, 2017
Merged

New lostfilm plugin#1681
liiight merged 4 commits intoFlexget:developfrom
Danfocus:Danfocus-patch-lostfilm

Conversation

@Danfocus
Copy link
Copy Markdown
Contributor

@Danfocus Danfocus commented Feb 10, 2017

original rss feed has link to episode page on site
this plugin make right links to torrent files

Motivation for changes:

lostfilm.tv change rss-feed

Detailed changes:

  • New site plugin lostfilm.py

Addressed issues:

Config usage if relevant (new plugin or updated schema):

lostfilm: yes

or

lostfilm:
  url: <url>

Log and/or tests output (preferably both):

...
2017-02-10 22:33 DEBUG    input_cache   lostfilm        storing to cache rss_90da24530a4756cb92568e3143af42a4 15 entries
2017-02-10 22:33 DEBUG    utils.requests lostfilm        Fetching URL https://www.lostfilm.tv/v_search.php?c=277&s=2&e=3 with args () and kwargs {'headers': {'Connection': 'keep-alive', u'cookie': u'uid=XXXXXX;
pass=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; usess=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; lf_session=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', u'User-Agent': u'FlexGet/2.9.18 (
www.flexget.com)'}, 'allow_redirects': True, u'timeout': 30}
2017-02-10 22:33 DEBUG    utils.requests lostfilm        Fetching URL http://retre.org/v3/?c=277&s=2&e=3&u=XXXXXX&h=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&n=1 with args () and kwargs {'headers': {'Connection': 'keep-a
live', u'cookie': u'uid=XXXXXX; pass=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; usess=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; lf_session=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', u
'User-Agent': u'FlexGet/2.9.18 (www.flexget.com)'}, 'allow_redirects': True, u'timeout': 30}
...

original rss feed has link to episode page on site
this plugin make right links to torrent files
@liiight
Copy link
Copy Markdown
Member

liiight commented Feb 10, 2017

I think you meant to do a UrlRewrite plugin. Look into the sites folder for some of those because this really isn't how it's done

@Danfocus
Copy link
Copy Markdown
Contributor Author

Danfocus commented Feb 10, 2017

No.
Rss from http://www.lostfilm.tv/rss.xml give link to episodes page, like https://lostfilm.tv/series/Outsiders/season_2/episode_3/
On this page has button to url https://www.lostfilm.tv/v_search.php?c=LOSTFILM_TVSHOW_ID&s=SEASON&e=EPISODE
On this page has redirect to retre.org where is 1-3 links to torrent files with different quality.
This is no UrlRewrite action. Every one original entry give one or two or three entries.

@liiight
Copy link
Copy Markdown
Member

liiight commented Feb 11, 2017

So this plugin is based on using the rss plugin with the relevant feed? If so, might be better to encapsulate this into the plugin:

lostfilm: rss_url

Remove rss plugin dependence
Change config
@Danfocus
Copy link
Copy Markdown
Contributor Author

Danfocus commented Feb 11, 2017

Ok. I rewrote plugin

@Danfocus Danfocus changed the title Add lostfilm.tv's rss link grabber New lostfilm plugin Feb 11, 2017
config = self.build_config(config)
if config is False:
return
rss = feedparser.parse(config['url'])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe wrap this with try, except

return
rss = feedparser.parse(config['url'])
if rss.get('status') != 200:
log.error('Received not 200 (OK) status')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can raise PluginError here, will abort task neatly

log.debug('Item doesn\'t have episode id in link')
continue
redirect_url = 'http://www.lostfilm.tv/v_search.php?' \
'c={}&s={}&e={}'.format(lostfilm_num, season_num, episode_num)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably best to pass this as a dict param:

params = {
    'c': lostfilm_num,
    's': season_num,
    'e': episode_num
}

then add it to request with query keyword:

response = task.requests.get(redirect_url, query=params)

continue

try:
response = task.requests.get(redirect_url)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure why you want this redirect logic, but if the previous block fails, there's no need to do this again.
You can add else to try, except block

Copy link
Copy Markdown
Contributor Author

@Danfocus Danfocus Feb 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a different requests.
v_search.php have meta refresh in head
<meta content="0; url=http://retre.org/v3/?c=288&amp;s=1&amp;e=14&amp;u=XXXXXX&amp;h=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&amp;n=1" http-equiv="refresh"/>

new_title_template = \
'{}.S{:02d}E{:02d}.{{}}.rus.LostFilm.TV.{{}}.torrent'\
.format(series_name_eng, season_num, episode_num)
except:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is like the worst thing you can do in python :-)

@Danfocus
Copy link
Copy Markdown
Contributor Author

Changes are made

@Danfocus
Copy link
Copy Markdown
Contributor Author

Changes are made

@liiight liiight merged commit e3b5049 into Flexget:develop Feb 15, 2017
@liiight
Copy link
Copy Markdown
Member

liiight commented Feb 15, 2017

Thanks! Can you update the wiki please?

@Danfocus
Copy link
Copy Markdown
Contributor Author

Thank you! I created a page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants