notpod / Notpod-1.x

The codebase for Notpod 1.x
http://www.notpod.com
GNU General Public License v3.0
6 stars 7 forks source link

issue with Interop.iTunesLib.dll and MockFileOrCDTrack.cs #10

Open sigpark opened 12 years ago

sigpark commented 12 years ago

I am using Visual Studio 2008. When I open the project, I get 36 compile errors all relating to the above .dll - the resource cannot be read (won't even display .dll properties). I have used the earlier version from itunes agent, and commented a couple of lines of c# code out in Notpod referring to rating - see below. Perhaps you have a different version registered on your development machine?

MockFileOrCDTrack.cs ITRatingKind AlbumRatingKind and ITRatingKind ratingKind that are refereto rating, as they must not be in the earlier version of .dll.

Purpose: I have customised the solution slightly to sync in a certain way for my Audi A6 SD music card by editing SyncPatternTranslator.cs.

I would appreciate if you can email me a version of the .dll that does read, or post up new source. I have tried the beta source as first posted on 14 April and beta source from today in case it was updated and the .dll from the stable 1.4 release (.dll is the same in these releases.

jaranflaath commented 12 years ago

Hi, apologies for the late response.

I am not entirely sure I understand what you're having problems with? Is the code not compiling with the ddls located in the lib folder?

sigpark commented 12 years ago

Hi Jaren,

Thank you for coming back to me. I thought it best to send a screen shot and a couple of attachments. I am not a programmer, but I know a little – so forgive me if my “language” is not correct.

Per my note I have added a little bit of “custom” code to the SyncPatternTranslator – at the end of your code mostly (search for “Simon”). I went to do the same in Notpod, but you can see from the attached screen shot that the Interop.iTunesLib.dll (1.13.0.0) with the Notpod source (all versions of your published source) cannot be read in Visual Studio – therefore the project will not compile.

I can use the Interop.iTunesLib.dll version that comes with iAgent (1.9.0.0) and then some references are missing in MockFileOrCDTrack.cs of Notpod

ITRatingKind AlbumRatingKind and ITRatingKind ratingKind

I simply comment out these reference to get Notpod to compile - see attached – search for “Simon”

So, I am looking for a later or different version of the Interop.iTunesLib.dll file that can be read in Visual Studio 8.

Also not from the screenshot there are two .png files missing – this does not cause any issue as you are aware – just thought you might like to know

Simon

-----Original Message----- From: Jaran Nilsen [mailto:reply@reply.github.com] Sent: 03 June 2012 15:44 To: sigpark Subject: Re: [Notpod-1.x] issue with Interop.iTunesLib.dll and MockFileOrCDTrack.cs (#10)

Hi, apologies for the late response.

I am not entirely sure I understand what you're having problems with? Is the code not compiling with the ddls located in the lib folder?


Reply to this email directly or view it on GitHub:

https://github.com/notpod/Notpod-1.x/issues/10#issuecomment-6086021 https://github.com/notpod/Notpod-1.x/issues/10#issuecomment-6086021 using System; using System.Collections.Generic; using System.Text; using iTunesLib; using Jaranweb.iTunesAgent.Configuration12; using log4net; namespace Jaranweb.iTunesAgent { ///

/// Contains methods for translating a synchronization patterns into a file paths.
/// </summary>

public class SyncPatternTranslator
{
    private static ILog l = LogManager.GetLogger(typeof(SyncPatternTranslator));
    /// <summary>
    /// Translate a SyncPattern into a string using the provided IITFileOrCDTrack.
    /// Currently translating the following macros:
    /// %ARTIST%        = The artist name
    /// %ALBUM%         = The album name
    /// %NAME%          = The track name
    /// %TRACKNUMSPACE% = The track number with a trailing space
    /// %TRACKNUM%      = The track number (no trailing space)
    /// </summary>
    /// <param name="pattern">SyncPattern to translate.</param>
    /// <param name="track">iTunes track containing track information.</param>
    /// <returns>A string representation of pattern and track.</returns>
    public static string Translate(SyncPattern pattern, IITFileOrCDTrack track)
    {
        try
        {
            if (track == null)
                l.Debug("Track is null!");

            if (track.Location == null)
            {
                l.Debug("track.Location is null!");
                throw new MissingTrackException(track);
            }

            /// Modified by Simon Park to force the default Artist / Album Pattern (remove Compilations pattern)
            /// and set Compliations type below when setting the Artist folder
            /// string patternstring = ((track.Compilation && pattern.CompilationsPattern != null && pattern.CompilationsPattern.Length > 0) ? pattern.CompilationsPattern : pattern.Pattern);

            string patternstring = pattern.Pattern;

            patternstring = TranslateArtist(pattern, track, patternstring);
            patternstring = TranslateAlbum(track.Album, patternstring);
            patternstring = TranslateName(track, patternstring);
            patternstring = TranslateTrackNumber(track, patternstring);
            patternstring = TranslateExtension(track, patternstring);

            l.Debug("patternstring=" + patternstring);

            return FileNameUtils.ConvertIllegalCharacters(patternstring);
        }
        catch (MissingTrackException ex)
        {
            throw ex;
        }
        catch (Exception ex)
        {
            string message = "Failed to translate track information according to the "
                + "defined pattern for this device (" + ex.Message + ").";

            l.Error(message, ex);
            throw new ArgumentException(message, ex);
        }            

    }

    /// <summary>
    /// Translate file extension.
    /// </summary>
    /// <param name="track"></param>
    /// <param name="patternstring"></param>
    /// <returns></returns>
    private static string TranslateExtension(IITFileOrCDTrack track, string patternstring)
    {
        int extensionstart = track.Location.LastIndexOf(".");
        patternstring = patternstring + track.Location.Substring(extensionstart, track.Location.Length - extensionstart);
        return patternstring;
    }

    /// <summary>
    /// Translate track name.
    /// </summary>
    /// <param name="track"></param>
    /// <param name="patternstring"></param>
    /// <returns></returns>
    private static string TranslateName(IITFileOrCDTrack track, string patternstring)
    {
        patternstring = patternstring.Replace("%NAME%", (track.Name == null ? "Unknown Track" : track.Name));
        return patternstring;
    }

    /// <summary>
    /// Translate track number.
    /// </summary>
    /// <param name="track"></param>
    /// <param name="patternstring"></param>
    /// <returns></returns>
    private static string TranslateTrackNumber(IITFileOrCDTrack track, string patternstring)
    {
        //Replace track number with a number only if the iTunes track has this field set
        if (track.TrackNumber != 0)
        {
            //%TRACKNUMSPACE%
            patternstring = patternstring.Replace("%TRACKNUMSPACE%",
                (track.TrackNumber.ToString().Length == 1 ?
                "0" + track.TrackNumber.ToString() : track.TrackNumber.ToString()) + " ");

            //%TRACKNUM%
            patternstring = patternstring.Replace("%TRACKNUM%",
                (track.TrackNumber.ToString().Length == 1 ?
                "0" + track.TrackNumber.ToString() : track.TrackNumber.ToString()));
        }
        else //If there are no track number set for the track
        {
            //%TRACKNUMSPACE%
            patternstring = patternstring.Replace("%TRACKNUMSPACE%", "");
            //%TRACKNUM%
            patternstring = patternstring.Replace("%TRACKNUM%", "");
        }
        return patternstring;
    }

    /// <summary>
    /// Translate track album.
    /// </summary>
    /// <param name="trackAlbum"></param>
    /// <param name="patternstring"></param>
    /// <returns></returns>
    private static string TranslateAlbum(string trackAlbum, string patternstring)
    {
        string album = (trackAlbum == null ? "Unknown Album" : trackAlbum);

        /// Modified by Simon Park for Now! Albums - gets most standard named Now Collections from Now 20 convention for SHORT "Now!" name
        if (trackAlbum.Length >= 29) if (trackAlbum.Substring(0, 29) == "Now That's What I Call Music!")
                album = "Now! " + trackAlbum.Substring(trackAlbum.Length - 3, 3);   

        patternstring = patternstring.Replace("%ALBUM%", album);
        return patternstring;
    }

    /// <summary>
    /// Translate track artist.
    /// </summary>
    /// <param name="pattern"></param>
    /// <param name="track"></param>
    /// <param name="patternstring"></param>
    /// <returns></returns>
    private static string TranslateArtist(SyncPattern pattern, IITFileOrCDTrack track, string patternstring)
    {

        /// Modified by Simon Park to use Album Artist instead of Artist
        string artist = (track.AlbumArtist == null ? "Unknown Artist" : track.AlbumArtist);

        /// Modified by Simon Park to set Compliations based on the Artist as Compliations - removing the Compliations Pattern String
        /// if (track.Compilation && pattern.CompilationsPattern != null && pattern.CompilationsPattern.Length > 0)
        if (track.Compilation == true)
            artist = "Compilations";

        /// Modified by Simon Park for Classical Music Compliations
        if (track.Compilation == true) if (track.Album.Contains("Classical"))
                artist = "Classical Compilations";
        if (track.Compilation == true) if (track.Genre == "Classical")
                artist = "Classical Compilations";

        /// Modified by Simon Park for Christmas Music Compliations
        if (track.Compilation == true) if (track.Genre == "Christmas")
                artist = "Christmas Compilations";

        /// Modified by Simon Park for Now! Albums - gets most standard named Now Collections from Now 20 convention
        if (track.Album.Length >= 29) if (track.Album.Substring(0, 29) == "Now That's What I Call Music!")
            artist = "Now! Albums";

            patternstring = patternstring.Replace("%ARTIST%", artist);
        return patternstring;
    }

}

} using System; using System.Collections.Generic; using System.Text; using iTunesLib;

namespace Notpod.Test { ///

/// Mock implementation of IITFileOrCDTrack.
/// </summary>

public class MockFileOrCDTrack : IITFileOrCDTrack
{
    private string album;
    private string artist;
    private string name;
    private int tracknumber;
    private string location;
    private int bookmarktime;
    private bool compilation;
    public int BookmarkTime
    {
        get
        {
            return bookmarktime;
        }
        set
        {
            this.bookmarktime = value;
        }
    }

    public int TrackNumber
    {
        get
        {
            return tracknumber;
        }
        set
        {
            this.tracknumber = value;
        }
    }

    public string Name
    {
        get
        {
            return name;
        }
        set
        {
            this.name = value;
        }
    }

    public string Album
    {
        get
        {
            return album;
        }
        set
        {
            album = value;
        }
    }

    public string Artist
    {
        get
        {
            return artist;
        }
        set
        {
            artist = value;
        }
    }

    public string Location
    {
        get { return location; }
        set { location = value; }
    }

    #region IITFileOrCDTrack Members

    public IITArtwork AddArtworkFromFile(string filePath)
    {
        throw new Exception("The method or operation is not implemented.");
    }

    public string AlbumArtist
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public IITArtworkCollection Artwork
    {
        get { throw new NotImplementedException(); }
    }

    public int BPM
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public int BitRate
    {
        get { throw new NotImplementedException(); }
    }

    public string Category
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public string Comment
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public bool Compilation
    {
        get
        {
            return compilation;
        }
        set
        {
            compilation = value;
        }
    }

    public string Composer
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public DateTime DateAdded
    {
        get { throw new NotImplementedException(); }
    }

    public void Delete()
    {
        throw new NotImplementedException();
    }

    public string Description
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public int DiscCount
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public int DiscNumber
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public int Duration
    {
        get { throw new NotImplementedException(); }
    }

    public string EQ
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public bool Enabled
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public string EpisodeID
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public int EpisodeNumber
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public bool ExcludeFromShuffle
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public int Finish
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public string Genre
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public void GetITObjectIDs(out int sourceID, out int playlistID, out int trackID, out int databaseID)
    {
        throw new NotImplementedException();
    }

    public string Grouping
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public int Index
    {
        get { throw new NotImplementedException(); }
    }

    public ITTrackKind Kind
    {
        get { throw new NotImplementedException(); }
    }

    public string KindAsString
    {
        get { throw new NotImplementedException(); }
    }

    public string LongDescription
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public string Lyrics
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public DateTime ModificationDate
    {
        get { throw new NotImplementedException(); }
    }

    public bool PartOfGaplessAlbum
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public void Play()
    {
        throw new NotImplementedException();
    }

    public int PlayOrderIndex
    {
        get { throw new NotImplementedException(); }
    }

    public int PlayedCount
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public DateTime PlayedDate
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public IITPlaylist Playlist
    {
        get { throw new NotImplementedException(); }
    }

    public bool Podcast
    {
        get { throw new NotImplementedException(); }
    }

    public int Rating
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public bool RememberBookmark
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public int SampleRate
    {
        get { throw new NotImplementedException(); }
    }

    public int SeasonNumber
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public string Show
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public int Size
    {
        get { throw new NotImplementedException(); }
    }

    public int Size64High
    {
        get { throw new NotImplementedException(); }
    }

    public int Size64Low
    {
        get { throw new NotImplementedException(); }
    }

    public int SkippedCount
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public DateTime SkippedDate
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public string SortAlbum
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public string SortAlbumArtist
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public string SortArtist
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public string SortComposer
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public string SortName
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public string SortShow
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public int Start
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public string Time
    {
        get { throw new NotImplementedException(); }
    }

    public int TrackCount
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public int TrackDatabaseID
    {
        get { throw new NotImplementedException(); }
    }

    public bool Unplayed
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public void UpdateInfoFromFile()
    {
        throw new NotImplementedException();
    }

    public void UpdatePodcastFeed()
    {
        throw new NotImplementedException();
    }

    public ITVideoKind VideoKind
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public int VolumeAdjustment
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public int Year
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public int playlistID
    {
        get { throw new NotImplementedException(); }
    }

    public int sourceID
    {
        get { throw new NotImplementedException(); }
    }

    public int trackID
    {
        get { throw new NotImplementedException(); }
    }

    #endregion

    public int AlbumRating {
        get {
            throw new NotImplementedException();
        }
        set {
            throw new NotImplementedException();
        }
    }
    // Removed by Simon for compatibility with Interop.iTunesLib.dll v1.9.0.0 - 1.13.00 does not work!

    //public ITRatingKind AlbumRatingKind {
        //get {
            //throw new NotImplementedException();
        //}
    //}

   // public ITRatingKind ratingKind {
        //get {
            //throw new NotImplementedException();
        //}
    //}

    public IITPlaylistCollection Playlists {
        get {
            throw new NotImplementedException();
        }
    }

    public DateTime ReleaseDate {
        get {
            throw new NotImplementedException();
        }
    }

    public void Reveal()
    {
        throw new NotImplementedException();
    }
}

}

jaranflaath commented 12 years ago

Thanks for the additional information. Let me look further into this and get back to you.

sigpark commented 12 years ago

Thanks Jaren - let me know if you need any more info. I assume you got attachments from me?

-s

-----Original Message----- From: Jaran Nilsen [mailto:reply@reply.github.com] Sent: 08 June 2012 12:46 To: sigpark Subject: Re: [Notpod-1.x] issue with Interop.iTunesLib.dll and MockFileOrCDTrack.cs (#10)

Thanks for the additional information. Let me look further into this and get back to you.


Reply to this email directly or view it on GitHub: https://github.com/notpod/Notpod-1.x/issues/10#issuecomment-6199827

jaranflaath commented 12 years ago

Hi again, sorry I did not receive any screenshots. Can you please send them through by mail? jaran.nilsen AT the google mail service.

sigpark commented 12 years ago

Hi Jaren,

Can you send me an alternative email address - I think this forum only supports "plain text" email. Otherwise, somewhere I can FTP or a "temp" gmail account - I won't pester you, but I think that the attachments are lost in the reply to this address.

Please advise,

Thanks, -simon

-----Original Message----- From: Jaran Nilsen [mailto:reply@reply.github.com] Sent: 20 June 2012 06:43 To: sigpark Subject: Re: [Notpod-1.x] issue with Interop.iTunesLib.dll and MockFileOrCDTrack.cs (#10)

Hi again, sorry I did not receive any screenshots. Can you please send them through by mail? jaran.nilsen AT the google mail service.


Reply to this email directly or view it on GitHub: https://github.com/notpod/Notpod-1.x/issues/10#issuecomment-6445522

jaranflaath commented 12 years ago

Please see my previous post. "the google mail service" is gmail.com :-) On Jun 20, 2012 9:03 PM, "sigpark" < reply@reply.github.com> wrote:

Hi Jaren,

Can you send me an alternative email address - I think this forum only supports "plain text" email. Otherwise, somewhere I can FTP or a "temp" gmail account - I won't pester you, but I think that the attachments are lost in the reply to this address.

Please advise,

Thanks, -simon

-----Original Message----- From: Jaran Nilsen [mailto:reply@reply.github.com] Sent: 20 June 2012 06:43 To: sigpark Subject: Re: [Notpod-1.x] issue with Interop.iTunesLib.dll and MockFileOrCDTrack.cs (#10)

Hi again, sorry I did not receive any screenshots. Can you please send them through by mail? jaran.nilsen AT the google mail service.


Reply to this email directly or view it on GitHub: https://github.com/notpod/Notpod-1.x/issues/10#issuecomment-6445522


Reply to this email directly or view it on GitHub: https://github.com/notpod/Notpod-1.x/issues/10#issuecomment-6463931