{"action":"created","issue":{"url":"https://api.github.com/repos/dchang0/torrentwatch-xa/issues/9","repository_url":"https://api.github.com/repos/dchang0/torrentwatch-xa","labels_url":"https://api.github.com/repos/dchang0/torrentwatch-xa/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/dchang0/torrentwatch-xa/issues/9/comments","events_url":"https://api.github.com/repos/dchang0/torrentwatch-xa/issues/9/events","html_url":"https://github.com/dchang0/torrentwatch-xa/issues/9","id":339939148,"node_id":"MDU6SXNzdWUzMzk5MzkxNDg=","number":9,"title":"Torrent links within some feeds don't get recognized","user":{"login":"efelon","id":10722552,"node_id":"MDQ6VXNlcjEwNzIyNTUy","avatar_url":"https://avatars1.githubusercontent.com/u/10722552?v=4","gravatar_id":"","url":"https://api.github.com/users/efelon","html_url":"https://github.com/efelon","followers_url":"https://api.github.com/users/efelon/followers","following_url":"https://api.github.com/users/efelon/following{/other_user}","gists_url":"https://api.github.com/users/efelon/gists{/gist_id}","starred_url":"https://api.github.com/users/efelon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/efelon/subscriptions","organizations_url":"https://api.github.com/users/efelon/orgs","repos_url":"https://api.github.com/users/efelon/repos","events_url":"https://api.github.com/users/efelon/events{/privacy}","received_events_url":"https://api.github.com/users/efelon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-07-10T17:31:32Z","updated_at":"2018-07-11T02:08:17Z","closed_at":null,"author_association":"NONE","body":"### Problem\r\n\r\nI came across this problem some time ago with the old torrentwatch-x on qnapnas where links from - I think it was kickass torrents - were not identified. Those links looked like this for example:\r\n\r\n> http://itorrents.org/torrent/42AEABA2CE6938C4C43F33FD609A9848FF4BB6F2.torrent?title=Drug-Lords-S02E02-WEB-x264-TVSLiCES\r\n\r\nThis is now also the case for limetorrents.cc (e.g. https://www.limetorrents.cc/rss/20/). They use the hash value as file name as you can see.\r\n\r\n### Solution\r\n\r\nAt that time I made a quick fix which also works for you. I tested it on limetorrents and briefly for some other feeds, so that there is no impact. Since I'm not fluent with git and github (Pull requests) and the fix is very small I hope you don't mind me putting it in here as text:\r\n\r\n> torrentwatch-xa/var/lib/torrentwatch-xa/lib/twxa_feed.php\r\n\r\nNew function:\r\n```\r\n/**\r\n * @brief Tries to extract a torrent hash from given URL constructs a magnet link from it\r\n * @param $url string\r\n * @return $url if no torrent SHA-1 hash string was found within $url\r\n * @return magnet-link containing extracted torrent hash\r\n */\r\nfunction magnetlink_getMagnetLinkFromURL($url)\r\n{\r\n\t$hash = preg_replace('/.*([a-fA-F0-9]{40}).*/', '$1', $url);\r\n\tif ($hash === $url)\r\n\t{\r\n\t\treturn $url;\r\n\t}\r\n\telse\r\n\t{\r\n\t\treturn \"magnet:?xt=urn:btih:$hash\";\r\n\t}\r\n}\r\n\r\n```\r\n\r\nChanged function :\r\n\r\n```\r\nfunction get_torrent_link($rs) {\r\n  $links = array();\r\n  $link = \"\";\r\n  if ((isset($rs['enclosure'])) && ($rs['enclosure']['type']=='application/x-bittorrent')) {\r\n     $links[] = $rs['enclosure']['url'];\r\n  } else {\r\n     if(isset($rs['link'])) {\r\n        $links[] = $rs['link'];\r\n     }\r\n     if(isset($rs['id']) && stristr($rs['id'], 'http://')) { // Atom\r\n        $links[] = $rs['id'];\r\n     }\r\n\t if(isset($rs['enclosure'])) { // RSS Enclosure\r\n        $links[] = $rs['enclosure']['url'];\r\n     }\r\n  }\r\n\r\n  if (count($links)==1) {\r\n\t$link = $links[0];\r\n\tif (stristr(\"$link\", \"torcache.net\") || stristr(\"$link\", \"itorrents.org\")){\r\n\t\t$link = magnetlink_getMagnetLinkFromURL($link);\r\n \t}\r\n  } else if (count($links) > 0) {\r\n\t$link = choose_torrent_link($links);\r\n  }\r\n  $link = str_replace(\" \", \"%20\", $link);\r\n  return html_entity_decode($link);\r\n}\r\n```\r\nOriginally I had the function _magnetlink_getMagnetLinkFromURL($url)_ in its own file and included it to _twxa_feed.php_.\r\n\r\nA little side effect is, that immediately after a torrent is added in this way, its title only shows the hash value until the name got resolved by transmission.\r\n\r\nMaybe you can improve this in many ways. I hope it helps anyway.\r\n"},"comment":{"url":"https://api.github.com/repos/dchang0/torrentwatch-xa/issues/comments/404021705","html_url":"https://github.com/dchang0/torrentwatch-xa/issues/9#issuecomment-404021705","issue_url":"https://api.github.com/repos/dchang0/torrentwatch-xa/issues/9","id":404021705,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNDAyMTcwNQ==","user":{"login":"dchang0","id":8884074,"node_id":"MDQ6VXNlcjg4ODQwNzQ=","avatar_url":"https://avatars0.githubusercontent.com/u/8884074?v=4","gravatar_id":"","url":"https://api.github.com/users/dchang0","html_url":"https://github.com/dchang0","followers_url":"https://api.github.com/users/dchang0/followers","following_url":"https://api.github.com/users/dchang0/following{/other_user}","gists_url":"https://api.github.com/users/dchang0/gists{/gist_id}","starred_url":"https://api.github.com/users/dchang0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dchang0/subscriptions","organizations_url":"https://api.github.com/users/dchang0/orgs","repos_url":"https://api.github.com/users/dchang0/repos","events_url":"https://api.github.com/users/dchang0/events{/privacy}","received_events_url":"https://api.github.com/users/dchang0/received_events","type":"User","site_admin":false},"created_at":"2018-07-11T02:08:17Z","updated_at":"2018-07-11T02:08:17Z","author_association":"OWNER","body":"It does look like CloudFlare is doing some sort of blocking, returning zero bytes of data and apparently closing the connection. I think that it thinks torrentwatch-xa is a bot or spider."}}
{"actor":{"display_login":"dchang0"}}