{"action":"created","issue":{"url":"https://api.github.com/repos/wmcbrine/pytivo/issues/18","labels_url":"https://api.github.com/repos/wmcbrine/pytivo/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/wmcbrine/pytivo/issues/18/comments","events_url":"https://api.github.com/repos/wmcbrine/pytivo/issues/18/events","html_url":"https://github.com/wmcbrine/pytivo/pull/18","id":111066980,"number":18,"title":"MP4 metadata improvements","user":{"login":"mackworth","id":117963,"avatar_url":"https://avatars.githubusercontent.com/u/117963?v=3","gravatar_id":"","url":"https://api.github.com/users/mackworth","html_url":"https://github.com/mackworth","followers_url":"https://api.github.com/users/mackworth/followers","following_url":"https://api.github.com/users/mackworth/following{/other_user}","gists_url":"https://api.github.com/users/mackworth/gists{/gist_id}","starred_url":"https://api.github.com/users/mackworth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mackworth/subscriptions","organizations_url":"https://api.github.com/users/mackworth/orgs","repos_url":"https://api.github.com/users/mackworth/repos","events_url":"https://api.github.com/users/mackworth/events{/privacy}","received_events_url":"https://api.github.com/users/mackworth/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-12T22:25:55Z","updated_at":"2015-10-13T03:17:44Z","closed_at":"2015-10-12T23:53:08Z","pull_request":{"url":"https://api.github.com/repos/wmcbrine/pytivo/pulls/18","html_url":"https://github.com/wmcbrine/pytivo/pull/18","diff_url":"https://github.com/wmcbrine/pytivo/pull/18.diff","patch_url":"https://github.com/wmcbrine/pytivo/pull/18.patch"},"body":"I've spent quite a while on improving the metadata communication from cTiVo to pyTivo through the MP4 embedded metadata in order to make the roundtrip to TiVo better. I've fixed several items on cTiVo's end, but I think the attached changes would improve pyTiVo's parsing of the metadata. I hope you agree. \r\n\r\nLet me start by acknowledging that I'm neither an expert on pyTiVo nor in Python, so happy to make any changes to this pull request that you think are appropriate. And if I've broken something, my apologies.\r\n\r\nThe changes are:\r\n1. The MP4 `tven` (TV episode ID) key is not the same as TiVo's `episodeNumber`. `tven` is set by iTunes to `SnEn`, but that's better read from `tvsn` and `tves`; so in TiVo's case, `tven` should be TiVo's programID. Then episodeNumber is constructed from` tvsn/tves` (or `programID` tven's SnEn format) as I think TiVo expects it to be numeric.\r\n2. AFAIK, Tivo's `isEpisode` is true for shows with episodes and movies (as opposed to, for example, news shows), so I set it to false iff the `programID` starts with `SH`, rather than if it's a TV show. (Note that the `stik` atom wasn't even being read by `mutagen/mp4.py`, and it's an integer.)\r\n3. If it's a Movie, then I think it's better to set `movieYear` than `originalAirDate` with the date.\r\n4. In order to read several of these mp4 atoms, I had to add the 8int and 32int parse/render routines into mutagen/mp4.py and the char routines in mutagen/_util.py. These are from updates to that project, but I only copied over the necessary routines. \r\n5. The last change may be somewhat controversial to you, but it would make the MP4 TiVo metadata complete. The idea is for those TiVo terms that don't map to any MP4 atom, just add a proprietary atom named `----:com.pyTivo.pyTivo:tiVoINFO` (in parallel to `---:com.apple.iTunes:iTunMOVI`) which would simply contain the JSON version of other pyTiVo attributes. This would then remove the need for the user to deal with the little .TXT files entirely, so that the metadata would simply follow along in the MP4 wherever it went. No effect on any programs that don't use it, but it would allow other programs to be more pyTiVo compliant. You'll see it's only a couple lines of code in pyTiVo. I hope you like this idea.\r\n\r\nFinally, while I was spending so much time in there, I noticed a couple of very minor things:\r\n\r\nFirst, if the TXT metadata contains `colorCode : 4`, then metadata['colorCode'] is set to 4, rather than [\"COLOR\",4], which breaks while generating the TVBus template. You'll see in the first commits, I wasn't sure how you'd prefer to fix it, and first did it by trying to maintain the array format, but finally decided that it was better to follow mpaaRating et al, and only keep the integer until the output in TVBus. I note in TVBus.tmpl, that there could be the same problem with showType, but I don't know what the right values are for that.\r\n\r\nSecondly, the wiki says that the TXT format is `Key : Value`, but the dump routine wasn't providing the space before the colon. \r\n"},"comment":{"url":"https://api.github.com/repos/wmcbrine/pytivo/issues/comments/147583586","html_url":"https://github.com/wmcbrine/pytivo/pull/18#issuecomment-147583586","issue_url":"https://api.github.com/repos/wmcbrine/pytivo/issues/18","id":147583586,"user":{"login":"mackworth","id":117963,"avatar_url":"https://avatars.githubusercontent.com/u/117963?v=3","gravatar_id":"","url":"https://api.github.com/users/mackworth","html_url":"https://github.com/mackworth","followers_url":"https://api.github.com/users/mackworth/followers","following_url":"https://api.github.com/users/mackworth/following{/other_user}","gists_url":"https://api.github.com/users/mackworth/gists{/gist_id}","starred_url":"https://api.github.com/users/mackworth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mackworth/subscriptions","organizations_url":"https://api.github.com/users/mackworth/orgs","repos_url":"https://api.github.com/users/mackworth/repos","events_url":"https://api.github.com/users/mackworth/events{/privacy}","received_events_url":"https://api.github.com/users/mackworth/received_events","type":"User","site_admin":false},"created_at":"2015-10-13T03:17:44Z","updated_at":"2015-10-13T03:17:44Z","body":"Great!  If you'd like to try it out, [cTiVo 2.4.1 beta4](https://github.com/dscottbuch/cTiVo/releases/download/2.4.1-beta.4/cTiVo.zip) has the MP4 code in it.  "}}