Last active
October 29, 2018 15:42
-
-
Save userhooke/b163693a83b692424ca7ddd8fdc8d510 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "import feedparser\nimport re\nimport logging", | |
"execution_count": 18, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "#import telegram\n#bot = ", | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')\nlogging.disable(logging.DEBUG)\nlogging.info('Script Started')", | |
"execution_count": 46, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": "2018-10-29 15:40:56,587 - INFO - Script Started\n" | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "kinozal = feedparser.parse('http://kinozal.tv/rss.xml')", | |
"execution_count": 26, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "try:\n f = open(\"looking_for.txt\", 'r')\n look_for = f.readlines()\n look_for = [x.strip() for x in look_for]\n logging.info(\"I'm looking for: {}\".format(look_for))\n f.close()\n \nexcept FileNotFoundError:\n logging.info(\"looking_for.txt not found! :(\")\n f = open(\"looking_for.txt\", 'w+')\n look_for = []\n f.close()", | |
"execution_count": 49, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": "2018-10-29 15:41:09,381 - INFO - I'm looking for: ['Test']\n" | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "def process_matched(name):\n logging.info('Found something new! ' + entry.title + '\\n' + entry.link)\n # remove entry from look_for\n look_for.remove(name)\n #bot.send_message(chat_id=206500344, text=entry.title + ' ' + entry.link)\n # or better, but not tested yet:\n #bot.send_message(chat_id=206500344, text=\"{}\\n{}\".format(entry.title, entry.link))", | |
"execution_count": 6, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "for entry in kinozal.entries:\n for name in look_for:\n match = re.search(name, entry.title)\n if match:\n process_matched(name)", | |
"execution_count": 50, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "# Update loocking_for.txt file\nw = open('looking_for.txt', 'w')\nfor title in look_for:\n w.write(title + \"\\n\")\nw.close()", | |
"execution_count": 8, | |
"outputs": [] | |
} | |
], | |
"metadata": { | |
"gist": { | |
"id": "", | |
"data": { | |
"description": "", | |
"public": true | |
} | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3", | |
"language": "python" | |
}, | |
"language_info": { | |
"name": "python", | |
"version": "3.6.5", | |
"mimetype": "text/x-python", | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"pygments_lexer": "ipython3", | |
"nbconvert_exporter": "python", | |
"file_extension": ".py" | |
}, | |
"varInspector": { | |
"window_display": false, | |
"cols": { | |
"lenName": 16, | |
"lenType": 16, | |
"lenVar": 40 | |
}, | |
"kernels_config": { | |
"python": { | |
"library": "var_list.py", | |
"delete_cmd_prefix": "del ", | |
"delete_cmd_postfix": "", | |
"varRefreshCmd": "print(var_dic_list())" | |
}, | |
"r": { | |
"library": "var_list.r", | |
"delete_cmd_prefix": "rm(", | |
"delete_cmd_postfix": ") ", | |
"varRefreshCmd": "cat(var_dic_list()) " | |
} | |
}, | |
"types_to_exclude": [ | |
"module", | |
"function", | |
"builtin_function_or_method", | |
"instance", | |
"_Feature" | |
] | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment